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::DeprecatedProfiling,
11 Feature::DeprecatedOtelTracesEndpoint,
12 Feature::DeprecatedOtelLogsEndpoint,
13 Feature::DeprecatedExtractSpansFromEvent,
14 Feature::DeprecatedStandaloneSpanIngestion,
15 Feature::DeprecatedSpanV2ExperimentalProcessing,
16];
17
18#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
20pub enum Feature {
21 #[serde(rename = "organizations:session-replay")]
25 SessionReplay,
26 #[serde(rename = "organizations:session-replay-recording-scrubbing")]
30 SessionReplayRecordingScrubbing,
31 #[serde(rename = "organizations:session-replay-video-disabled")]
35 SessionReplayVideoDisabled,
36 #[serde(rename = "organizations:relay-playstation-ingestion")]
40 PlaystationIngestion,
41 #[serde(rename = "projects:discard-transaction")]
45 DiscardTransaction,
46 #[serde(rename = "organizations:continuous-profiling")]
50 ContinuousProfiling,
51 #[serde(rename = "organizations:continuous-profiling-perfetto")]
58 ContinuousProfilingPerfetto,
59 #[serde(rename = "organizations:ourlogs-ingestion")]
63 OurLogsIngestion,
64 #[serde(rename = "organizations:tracemetrics-ingestion")]
68 TraceMetricsIngestion,
69 #[serde(rename = "organizations:relay-automatic-json-expansion")]
75 AutomaticJsonExpansion,
76 #[serde(rename = "projects:relay-automatic-json-expansion")]
80 ProjectAutomaticJsonExpansion,
81 #[doc(hidden)]
83 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
84 IngestUnsampledProfiles,
85 #[doc(hidden)]
87 #[serde(rename = "organizations:user-feedback-ingest")]
88 UserReportV2Ingest,
89 #[doc(hidden)]
90 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
91 ViewHierarchyScrubbing,
92 #[serde(rename = "organizations:performance-issues-spans")]
94 PerformanceIssuesSpans,
95 #[serde(rename = "projects:span-v2-attachment-processing")]
97 SpanV2AttachmentProcessing,
98 #[serde(rename = "projects:trace-attachment-processing")]
100 TraceAttachmentProcessing,
101 #[serde(rename = "projects:relay-playstation-uploads")]
103 PlaystationUploads,
104 #[serde(rename = "projects:relay-nintendo-event-rewrite")]
106 NintendoEventRewrite,
107 #[serde(rename = "projects:relay-minidump-uploads")]
109 MinidumpUploads,
110 #[serde(rename = "organizations:gpu-crash-symbolication")]
113 NvGpuCrashSplit,
114 #[serde(rename = "projects:resumable-uploads")]
116 ResumableUpload,
117 #[serde(rename = "organizations:span-v2-otlp-processing")]
121 DeprecatedSpanV2OtlpProcessing,
122 #[doc(hidden)]
124 #[serde(rename = "projects:span-metrics-extraction")]
125 DeprecatedExtractCommonSpanMetricsFromEvent,
126 #[doc(hidden)]
128 #[serde(rename = "projects:span-metrics-extraction-addons")]
129 DeprecatedExtractAddonsSpanMetricsFromEvent,
130 #[doc(hidden)]
132 #[serde(rename = "organizations:indexed-spans-extraction")]
133 DeprecatedExtractSpansFromEvent,
134 #[doc(hidden)]
138 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
139 DeprecatedOtelTracesEndpoint,
140 #[doc(hidden)]
144 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
145 DeprecatedOtelLogsEndpoint,
146 #[doc(hidden)]
150 #[serde(rename = "organizations:standalone-span-ingestion")]
151 DeprecatedStandaloneSpanIngestion,
152 #[doc(hidden)]
156 #[serde(rename = "organizations:profiling")]
157 DeprecatedProfiling,
158 #[doc(hidden)]
162 #[serde(rename = "projects:span-v2-experimental-processing")]
163 DeprecatedSpanV2ExperimentalProcessing,
164
165 #[doc(hidden)]
167 #[serde(other)]
168 Unknown,
169}
170
171#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
173pub struct FeatureSet(pub BTreeSet<Feature>);
174
175impl FeatureSet {
176 pub fn is_empty(&self) -> bool {
178 self.0.is_empty()
179 }
180
181 pub fn has(&self, feature: Feature) -> bool {
183 self.0.contains(&feature)
184 }
185}
186
187impl FromIterator<Feature> for FeatureSet {
188 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
189 Self(BTreeSet::from_iter(iter))
190 }
191}
192
193impl<'de> Deserialize<'de> for FeatureSet {
194 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
195 where
196 D: serde::Deserializer<'de>,
197 {
198 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
199 set.remove(&Feature::Unknown);
200 Ok(Self(set))
201 }
202}
203
204#[cfg(test)]
205mod tests {
206 use super::*;
207
208 #[test]
209 fn roundtrip() {
210 let features: FeatureSet =
211 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
212 assert_eq!(
213 &features,
214 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
215 );
216 assert_eq!(
217 serde_json::to_string(&features).unwrap(),
218 r#"["organizations:session-replay"]"#
219 );
220 }
221
222 #[test]
223 fn test_continuous_profiling_perfetto_serde() {
224 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
226 assert_eq!(
227 serialized,
228 r#""organizations:continuous-profiling-perfetto""#
229 );
230
231 let deserialized: Feature =
232 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
233 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
234 }
235}