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-heroku-log-drain-endpoint")]
40 HerokuLogDrainEndpoint,
41 #[serde(rename = "organizations:relay-playstation-ingestion")]
45 PlaystationIngestion,
46 #[serde(rename = "projects:discard-transaction")]
50 DiscardTransaction,
51 #[serde(rename = "organizations:continuous-profiling")]
55 ContinuousProfiling,
56 #[serde(rename = "organizations:continuous-profiling-perfetto")]
63 ContinuousProfilingPerfetto,
64 #[serde(rename = "organizations:ourlogs-ingestion")]
68 OurLogsIngestion,
69 #[serde(rename = "organizations:tracemetrics-ingestion")]
73 TraceMetricsIngestion,
74 #[serde(rename = "organizations:browser-report-ingestion")]
78 BrowserReportIngestion,
79 #[serde(rename = "projects:relay-automatic-json-expansion")]
83 ProjectAutomaticJsonExpansion,
84 #[doc(hidden)]
86 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
87 IngestUnsampledProfiles,
88 #[doc(hidden)]
90 #[serde(rename = "organizations:user-feedback-ingest")]
91 UserReportV2Ingest,
92 #[doc(hidden)]
93 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
94 ViewHierarchyScrubbing,
95 #[serde(rename = "organizations:performance-issues-spans")]
97 PerformanceIssuesSpans,
98 #[serde(rename = "projects:span-v2-attachment-processing")]
100 SpanV2AttachmentProcessing,
101 #[serde(rename = "projects:trace-attachment-processing")]
103 TraceAttachmentProcessing,
104 #[serde(rename = "projects:relay-playstation-uploads")]
106 PlaystationUploads,
107 #[serde(rename = "projects:relay-nintendo-event-rewrite")]
109 NintendoEventRewrite,
110 #[serde(rename = "projects:relay-unreal-crash-context-stacktrace")]
112 UnrealCrashContextStacktrace,
113 #[serde(rename = "projects:relay-minidump-uploads")]
115 MinidumpUploads,
116 #[serde(rename = "organizations:gpu-crash-symbolication")]
119 NvGpuCrashSplit,
120 #[serde(rename = "projects:resumable-uploads")]
122 ResumableUpload,
123 #[serde(rename = "organizations:span-v2-otlp-processing")]
127 DeprecatedSpanV2OtlpProcessing,
128 #[doc(hidden)]
130 #[serde(rename = "projects:span-metrics-extraction")]
131 DeprecatedExtractCommonSpanMetricsFromEvent,
132 #[doc(hidden)]
134 #[serde(rename = "projects:span-metrics-extraction-addons")]
135 DeprecatedExtractAddonsSpanMetricsFromEvent,
136 #[doc(hidden)]
138 #[serde(rename = "organizations:indexed-spans-extraction")]
139 DeprecatedExtractSpansFromEvent,
140 #[doc(hidden)]
144 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
145 DeprecatedOtelTracesEndpoint,
146 #[doc(hidden)]
150 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
151 DeprecatedOtelLogsEndpoint,
152 #[doc(hidden)]
156 #[serde(rename = "organizations:standalone-span-ingestion")]
157 DeprecatedStandaloneSpanIngestion,
158 #[doc(hidden)]
162 #[serde(rename = "organizations:profiling")]
163 DeprecatedProfiling,
164 #[doc(hidden)]
168 #[serde(rename = "projects:span-v2-experimental-processing")]
169 DeprecatedSpanV2ExperimentalProcessing,
170
171 #[doc(hidden)]
173 #[serde(other)]
174 Unknown,
175}
176
177#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
179pub struct FeatureSet(pub BTreeSet<Feature>);
180
181impl FeatureSet {
182 pub fn is_empty(&self) -> bool {
184 self.0.is_empty()
185 }
186
187 pub fn has(&self, feature: Feature) -> bool {
189 self.0.contains(&feature)
190 }
191}
192
193impl FromIterator<Feature> for FeatureSet {
194 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
195 Self(BTreeSet::from_iter(iter))
196 }
197}
198
199impl<'de> Deserialize<'de> for FeatureSet {
200 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
201 where
202 D: serde::Deserializer<'de>,
203 {
204 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
205 set.remove(&Feature::Unknown);
206 Ok(Self(set))
207 }
208}
209
210#[cfg(test)]
211mod tests {
212 use super::*;
213
214 #[test]
215 fn roundtrip() {
216 let features: FeatureSet =
217 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
218 assert_eq!(
219 &features,
220 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
221 );
222 assert_eq!(
223 serde_json::to_string(&features).unwrap(),
224 r#"["organizations:session-replay"]"#
225 );
226 }
227
228 #[test]
229 fn test_continuous_profiling_perfetto_serde() {
230 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
232 assert_eq!(
233 serialized,
234 r#""organizations:continuous-profiling-perfetto""#
235 );
236
237 let deserialized: Feature =
238 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
239 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
240 }
241}