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:browser-report-ingestion")]
73 BrowserReportIngestion,
74 #[serde(rename = "projects:relay-automatic-json-expansion")]
78 ProjectAutomaticJsonExpansion,
79 #[doc(hidden)]
81 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
82 IngestUnsampledProfiles,
83 #[doc(hidden)]
85 #[serde(rename = "organizations:user-feedback-ingest")]
86 UserReportV2Ingest,
87 #[doc(hidden)]
88 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
89 ViewHierarchyScrubbing,
90 #[serde(rename = "organizations:performance-issues-spans")]
92 PerformanceIssuesSpans,
93 #[serde(rename = "projects:span-v2-attachment-processing")]
95 SpanV2AttachmentProcessing,
96 #[serde(rename = "projects:trace-attachment-processing")]
98 TraceAttachmentProcessing,
99 #[serde(rename = "projects:relay-playstation-uploads")]
101 PlaystationUploads,
102 #[serde(rename = "projects:relay-nintendo-event-rewrite")]
104 NintendoEventRewrite,
105 #[serde(rename = "projects:relay-minidump-uploads")]
107 MinidumpUploads,
108 #[serde(rename = "organizations:gpu-crash-symbolication")]
111 NvGpuCrashSplit,
112 #[serde(rename = "projects:resumable-uploads")]
114 ResumableUpload,
115 #[serde(rename = "organizations:span-v2-otlp-processing")]
119 DeprecatedSpanV2OtlpProcessing,
120 #[doc(hidden)]
122 #[serde(rename = "projects:span-metrics-extraction")]
123 DeprecatedExtractCommonSpanMetricsFromEvent,
124 #[doc(hidden)]
126 #[serde(rename = "projects:span-metrics-extraction-addons")]
127 DeprecatedExtractAddonsSpanMetricsFromEvent,
128 #[doc(hidden)]
130 #[serde(rename = "organizations:indexed-spans-extraction")]
131 DeprecatedExtractSpansFromEvent,
132 #[doc(hidden)]
136 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
137 DeprecatedOtelTracesEndpoint,
138 #[doc(hidden)]
142 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
143 DeprecatedOtelLogsEndpoint,
144 #[doc(hidden)]
148 #[serde(rename = "organizations:standalone-span-ingestion")]
149 DeprecatedStandaloneSpanIngestion,
150 #[doc(hidden)]
154 #[serde(rename = "organizations:profiling")]
155 DeprecatedProfiling,
156 #[doc(hidden)]
160 #[serde(rename = "projects:span-v2-experimental-processing")]
161 DeprecatedSpanV2ExperimentalProcessing,
162
163 #[doc(hidden)]
165 #[serde(other)]
166 Unknown,
167}
168
169#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
171pub struct FeatureSet(pub BTreeSet<Feature>);
172
173impl FeatureSet {
174 pub fn is_empty(&self) -> bool {
176 self.0.is_empty()
177 }
178
179 pub fn has(&self, feature: Feature) -> bool {
181 self.0.contains(&feature)
182 }
183}
184
185impl FromIterator<Feature> for FeatureSet {
186 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
187 Self(BTreeSet::from_iter(iter))
188 }
189}
190
191impl<'de> Deserialize<'de> for FeatureSet {
192 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
193 where
194 D: serde::Deserializer<'de>,
195 {
196 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
197 set.remove(&Feature::Unknown);
198 Ok(Self(set))
199 }
200}
201
202#[cfg(test)]
203mod tests {
204 use super::*;
205
206 #[test]
207 fn roundtrip() {
208 let features: FeatureSet =
209 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
210 assert_eq!(
211 &features,
212 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
213 );
214 assert_eq!(
215 serde_json::to_string(&features).unwrap(),
216 r#"["organizations:session-replay"]"#
217 );
218 }
219
220 #[test]
221 fn test_continuous_profiling_perfetto_serde() {
222 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
224 assert_eq!(
225 serialized,
226 r#""organizations:continuous-profiling-perfetto""#
227 );
228
229 let deserialized: Feature =
230 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
231 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
232 }
233}