relay_dynamic_config/
feature.rs1use std::collections::BTreeSet;
2
3use serde::{Deserialize, Serialize};
4
5pub const GRADUATED_FEATURE_FLAGS: &[Feature] = &[
8 Feature::UserReportV2Ingest,
9 Feature::IngestUnsampledProfiles,
10 Feature::ScrubMongoDbDescriptions,
11 Feature::DeprecatedExtractSpansFromEvent,
12];
13
14#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
16pub enum Feature {
17 #[serde(rename = "organizations:session-replay")]
21 SessionReplay,
22 #[serde(rename = "organizations:session-replay-recording-scrubbing")]
26 SessionReplayRecordingScrubbing,
27 #[serde(rename = "organizations:session-replay-video-disabled")]
31 SessionReplayVideoDisabled,
32 #[serde(rename = "organizations:device-class-synthesis")]
38 DeviceClassSynthesis,
39 #[serde(rename = "organizations:custom-metrics")]
43 CustomMetrics,
44 #[serde(rename = "organizations:profiling")]
48 Profiling,
49 #[serde(rename = "organizations:standalone-span-ingestion")]
53 StandaloneSpanIngestion,
54 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
58 OtelTracesEndpoint,
59 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
63 OtelLogsEndpoint,
64 #[serde(rename = "organizations:relay-vercel-log-drain-endpoint")]
68 VercelLogDrainEndpoint,
69 #[serde(rename = "organizations:relay-playstation-ingestion")]
73 PlaystationIngestion,
74 #[serde(rename = "projects:discard-transaction")]
78 DiscardTransaction,
79 #[serde(rename = "organizations:continuous-profiling")]
83 ContinuousProfiling,
84 #[serde(rename = "organizations:continuous-profiling-beta")]
88 ContinuousProfilingBeta,
89 #[serde(rename = "organizations:continuous-profiling-beta-ingest")]
93 ContinuousProfilingBetaIngest,
94 #[serde(rename = "organizations:ourlogs-ingestion")]
98 OurLogsIngestion,
99 #[serde(rename = "organizations:tracemetrics-ingestion")]
103 TraceMetricsIngestion,
104 #[doc(hidden)]
106 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
107 IngestUnsampledProfiles,
108 #[doc(hidden)]
110 #[serde(rename = "organizations:user-feedback-ingest")]
111 UserReportV2Ingest,
112 #[doc(hidden)]
114 #[serde(rename = "organizations:performance-queries-mongodb-extraction")]
115 ScrubMongoDbDescriptions,
116 #[doc(hidden)]
117 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
118 ViewHierarchyScrubbing,
119 #[serde(rename = "organizations:performance-issues-spans")]
121 PerformanceIssuesSpans,
122 #[serde(rename = "projects:span-v2-experimental-processing")]
124 SpanV2ExperimentalProcessing,
125 #[doc(hidden)]
127 #[serde(rename = "projects:span-metrics-extraction")]
128 DeprecatedExtractCommonSpanMetricsFromEvent,
129 #[doc(hidden)]
131 #[serde(rename = "projects:span-metrics-extraction-addons")]
132 DeprecatedExtractAddonsSpanMetricsFromEvent,
133 #[doc(hidden)]
135 #[serde(rename = "organizations:indexed-spans-extraction")]
136 DeprecatedExtractSpansFromEvent,
137 #[doc(hidden)]
139 #[serde(other)]
140 Unknown,
141}
142
143#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
145pub struct FeatureSet(pub BTreeSet<Feature>);
146
147impl FeatureSet {
148 pub fn is_empty(&self) -> bool {
150 self.0.is_empty()
151 }
152
153 pub fn has(&self, feature: Feature) -> bool {
155 self.0.contains(&feature)
156 }
157}
158
159impl FromIterator<Feature> for FeatureSet {
160 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
161 Self(BTreeSet::from_iter(iter))
162 }
163}
164
165impl<'de> Deserialize<'de> for FeatureSet {
166 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
167 where
168 D: serde::Deserializer<'de>,
169 {
170 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
171 set.remove(&Feature::Unknown);
172 Ok(Self(set))
173 }
174}
175
176#[cfg(test)]
177mod tests {
178 use super::*;
179
180 #[test]
181 fn roundtrip() {
182 let features: FeatureSet =
183 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
184 assert_eq!(
185 &features,
186 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
187 );
188 assert_eq!(
189 serde_json::to_string(&features).unwrap(),
190 r#"["organizations:session-replay"]"#
191 );
192 }
193}