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:ourlogs-ingestion")]
83 OurLogsIngestion,
84 #[serde(rename = "organizations:tracemetrics-ingestion")]
88 TraceMetricsIngestion,
89 #[doc(hidden)]
91 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
92 IngestUnsampledProfiles,
93 #[doc(hidden)]
95 #[serde(rename = "organizations:user-feedback-ingest")]
96 UserReportV2Ingest,
97 #[doc(hidden)]
99 #[serde(rename = "organizations:performance-queries-mongodb-extraction")]
100 ScrubMongoDbDescriptions,
101 #[doc(hidden)]
102 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
103 ViewHierarchyScrubbing,
104 #[serde(rename = "organizations:performance-issues-spans")]
106 PerformanceIssuesSpans,
107 #[serde(rename = "projects:span-v2-experimental-processing")]
109 SpanV2ExperimentalProcessing,
110 #[serde(rename = "projects:span-v2-attachment-processing")]
112 SpanV2AttachmentProcessing,
113 #[serde(rename = "projects:trace-attachment-processing")]
115 TraceAttachmentProcessing,
116 #[serde(rename = "projects:relay-upload-endpoint")]
118 UploadEndpoint,
119 #[serde(rename = "organizations:relay-new-error-processing")]
121 NewErrorProcessing,
122 #[serde(rename = "projects:relay-playstation-uploads")]
124 PlaystationUploads,
125
126 #[serde(rename = "organizations:span-v2-otlp-processing")]
130 DeprecatedSpanV2OtlpProcessing,
131 #[doc(hidden)]
133 #[serde(rename = "projects:span-metrics-extraction")]
134 DeprecatedExtractCommonSpanMetricsFromEvent,
135 #[doc(hidden)]
137 #[serde(rename = "projects:span-metrics-extraction-addons")]
138 DeprecatedExtractAddonsSpanMetricsFromEvent,
139 #[doc(hidden)]
141 #[serde(rename = "organizations:indexed-spans-extraction")]
142 DeprecatedExtractSpansFromEvent,
143 #[doc(hidden)]
145 #[serde(other)]
146 Unknown,
147}
148
149#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
151pub struct FeatureSet(pub BTreeSet<Feature>);
152
153impl FeatureSet {
154 pub fn is_empty(&self) -> bool {
156 self.0.is_empty()
157 }
158
159 pub fn has(&self, feature: Feature) -> bool {
161 self.0.contains(&feature)
162 }
163}
164
165impl FromIterator<Feature> for FeatureSet {
166 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
167 Self(BTreeSet::from_iter(iter))
168 }
169}
170
171impl<'de> Deserialize<'de> for FeatureSet {
172 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
173 where
174 D: serde::Deserializer<'de>,
175 {
176 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
177 set.remove(&Feature::Unknown);
178 Ok(Self(set))
179 }
180}
181
182#[cfg(test)]
183mod tests {
184 use super::*;
185
186 #[test]
187 fn roundtrip() {
188 let features: FeatureSet =
189 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
190 assert_eq!(
191 &features,
192 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
193 );
194 assert_eq!(
195 serde_json::to_string(&features).unwrap(),
196 r#"["organizations:session-replay"]"#
197 );
198 }
199}