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-playstation-ingestion")]
68 PlaystationIngestion,
69 #[serde(rename = "projects:discard-transaction")]
73 DiscardTransaction,
74 #[serde(rename = "organizations:continuous-profiling")]
78 ContinuousProfiling,
79 #[serde(rename = "organizations:continuous-profiling-beta")]
83 ContinuousProfilingBeta,
84 #[serde(rename = "organizations:continuous-profiling-beta-ingest")]
88 ContinuousProfilingBetaIngest,
89 #[serde(rename = "organizations:ourlogs-ingestion")]
93 OurLogsIngestion,
94 #[serde(rename = "organizations:tracemetrics-ingestion")]
98 TraceMetricsIngestion,
99 #[doc(hidden)]
101 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
102 IngestUnsampledProfiles,
103 #[doc(hidden)]
105 #[serde(rename = "organizations:user-feedback-ingest")]
106 UserReportV2Ingest,
107 #[doc(hidden)]
109 #[serde(rename = "organizations:performance-queries-mongodb-extraction")]
110 ScrubMongoDbDescriptions,
111 #[doc(hidden)]
112 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
113 ViewHierarchyScrubbing,
114 #[serde(rename = "organizations:performance-issues-spans")]
116 PerformanceIssuesSpans,
117 #[serde(rename = "projects:span-v2-experimental-processing")]
119 SpanV2ExperimentalProcessing,
120 #[serde(rename = "organizations:span-v2-otlp-processing")]
122 SpanV2OtlpProcessing,
123 #[doc(hidden)]
125 #[serde(rename = "projects:span-metrics-extraction")]
126 DeprecatedExtractCommonSpanMetricsFromEvent,
127 #[doc(hidden)]
129 #[serde(rename = "projects:span-metrics-extraction-addons")]
130 DeprecatedExtractAddonsSpanMetricsFromEvent,
131 #[doc(hidden)]
133 #[serde(rename = "organizations:indexed-spans-extraction")]
134 DeprecatedExtractSpansFromEvent,
135 #[serde(rename = "projects:span-v2-attachment-processing")]
137 SpanV2AttachmentProcessing,
138 #[serde(rename = "projects:trace-attachment-processing")]
140 TraceAttachmentProcessing,
141 #[doc(hidden)]
143 #[serde(other)]
144 Unknown,
145}
146
147#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
149pub struct FeatureSet(pub BTreeSet<Feature>);
150
151impl FeatureSet {
152 pub fn is_empty(&self) -> bool {
154 self.0.is_empty()
155 }
156
157 pub fn has(&self, feature: Feature) -> bool {
159 self.0.contains(&feature)
160 }
161}
162
163impl FromIterator<Feature> for FeatureSet {
164 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
165 Self(BTreeSet::from_iter(iter))
166 }
167}
168
169impl<'de> Deserialize<'de> for FeatureSet {
170 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
171 where
172 D: serde::Deserializer<'de>,
173 {
174 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
175 set.remove(&Feature::Unknown);
176 Ok(Self(set))
177 }
178}
179
180#[cfg(test)]
181mod tests {
182 use super::*;
183
184 #[test]
185 fn roundtrip() {
186 let features: FeatureSet =
187 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
188 assert_eq!(
189 &features,
190 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
191 );
192 assert_eq!(
193 serde_json::to_string(&features).unwrap(),
194 r#"["organizations:session-replay"]"#
195 );
196 }
197}