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-minidump-uploads")]
112 MinidumpUploads,
113 #[serde(rename = "organizations:gpu-crash-symbolication")]
116 NvGpuCrashSplit,
117 #[serde(rename = "projects:resumable-uploads")]
119 ResumableUpload,
120 #[serde(rename = "organizations:span-v2-otlp-processing")]
124 DeprecatedSpanV2OtlpProcessing,
125 #[doc(hidden)]
127 #[serde(rename = "projects:span-metrics-extraction")]
128 DeprecatedExtractCommonSpanMetricsFromEvent,
129 #[doc(hidden)]
131 #[serde(rename = "projects:span-metrics-extraction-addons")]
132 DeprecatedExtractAddonsSpanMetricsFromEvent,
133 #[doc(hidden)]
135 #[serde(rename = "organizations:indexed-spans-extraction")]
136 DeprecatedExtractSpansFromEvent,
137 #[doc(hidden)]
141 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
142 DeprecatedOtelTracesEndpoint,
143 #[doc(hidden)]
147 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
148 DeprecatedOtelLogsEndpoint,
149 #[doc(hidden)]
153 #[serde(rename = "organizations:standalone-span-ingestion")]
154 DeprecatedStandaloneSpanIngestion,
155 #[doc(hidden)]
159 #[serde(rename = "organizations:profiling")]
160 DeprecatedProfiling,
161 #[doc(hidden)]
165 #[serde(rename = "projects:span-v2-experimental-processing")]
166 DeprecatedSpanV2ExperimentalProcessing,
167
168 #[doc(hidden)]
170 #[serde(other)]
171 Unknown,
172}
173
174#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
176pub struct FeatureSet(pub BTreeSet<Feature>);
177
178impl FeatureSet {
179 pub fn is_empty(&self) -> bool {
181 self.0.is_empty()
182 }
183
184 pub fn has(&self, feature: Feature) -> bool {
186 self.0.contains(&feature)
187 }
188}
189
190impl FromIterator<Feature> for FeatureSet {
191 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
192 Self(BTreeSet::from_iter(iter))
193 }
194}
195
196impl<'de> Deserialize<'de> for FeatureSet {
197 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
198 where
199 D: serde::Deserializer<'de>,
200 {
201 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
202 set.remove(&Feature::Unknown);
203 Ok(Self(set))
204 }
205}
206
207#[cfg(test)]
208mod tests {
209 use super::*;
210
211 #[test]
212 fn roundtrip() {
213 let features: FeatureSet =
214 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
215 assert_eq!(
216 &features,
217 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
218 );
219 assert_eq!(
220 serde_json::to_string(&features).unwrap(),
221 r#"["organizations:session-replay"]"#
222 );
223 }
224
225 #[test]
226 fn test_continuous_profiling_perfetto_serde() {
227 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
229 assert_eq!(
230 serialized,
231 r#""organizations:continuous-profiling-perfetto""#
232 );
233
234 let deserialized: Feature =
235 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
236 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
237 }
238}