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 = "projects:span-v2-attachment-processing")]
122 SpanV2AttachmentProcessing,
123 #[serde(rename = "projects:trace-attachment-processing")]
125 TraceAttachmentProcessing,
126 #[serde(rename = "organizations:new-replay-processing")]
128 NewReplayProcessing,
129 #[serde(rename = "projects:relay-upload-endpoint")]
131 UploadEndpoint,
132
133 #[serde(rename = "organizations:span-v2-otlp-processing")]
137 DeprecatedSpanV2OtlpProcessing,
138 #[doc(hidden)]
140 #[serde(rename = "projects:span-metrics-extraction")]
141 DeprecatedExtractCommonSpanMetricsFromEvent,
142 #[doc(hidden)]
144 #[serde(rename = "projects:span-metrics-extraction-addons")]
145 DeprecatedExtractAddonsSpanMetricsFromEvent,
146 #[doc(hidden)]
148 #[serde(rename = "organizations:indexed-spans-extraction")]
149 DeprecatedExtractSpansFromEvent,
150 #[doc(hidden)]
152 #[serde(other)]
153 Unknown,
154}
155
156#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
158pub struct FeatureSet(pub BTreeSet<Feature>);
159
160impl FeatureSet {
161 pub fn is_empty(&self) -> bool {
163 self.0.is_empty()
164 }
165
166 pub fn has(&self, feature: Feature) -> bool {
168 self.0.contains(&feature)
169 }
170}
171
172impl FromIterator<Feature> for FeatureSet {
173 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
174 Self(BTreeSet::from_iter(iter))
175 }
176}
177
178impl<'de> Deserialize<'de> for FeatureSet {
179 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
180 where
181 D: serde::Deserializer<'de>,
182 {
183 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
184 set.remove(&Feature::Unknown);
185 Ok(Self(set))
186 }
187}
188
189#[cfg(test)]
190mod tests {
191 use super::*;
192
193 #[test]
194 fn roundtrip() {
195 let features: FeatureSet =
196 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
197 assert_eq!(
198 &features,
199 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
200 );
201 assert_eq!(
202 serde_json::to_string(&features).unwrap(),
203 r#"["organizations:session-replay"]"#
204 );
205 }
206}