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-client-asn-lookup")]
106 ClientAsnLookup,
107 #[serde(rename = "projects:relay-playstation-uploads")]
109 PlaystationUploads,
110 #[serde(rename = "projects:relay-nintendo-event-rewrite")]
112 NintendoEventRewrite,
113 #[serde(rename = "projects:relay-unreal-crash-context-stacktrace")]
115 UnrealCrashContextStacktrace,
116 #[serde(rename = "projects:relay-minidump-uploads")]
118 MinidumpUploads,
119 #[serde(rename = "organizations:gpu-crash-symbolication")]
122 NvGpuCrashSplit,
123 #[serde(rename = "projects:resumable-uploads")]
125 ResumableUpload,
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)]
147 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
148 DeprecatedOtelTracesEndpoint,
149 #[doc(hidden)]
153 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
154 DeprecatedOtelLogsEndpoint,
155 #[doc(hidden)]
159 #[serde(rename = "organizations:standalone-span-ingestion")]
160 DeprecatedStandaloneSpanIngestion,
161 #[doc(hidden)]
165 #[serde(rename = "organizations:profiling")]
166 DeprecatedProfiling,
167 #[doc(hidden)]
171 #[serde(rename = "projects:span-v2-experimental-processing")]
172 DeprecatedSpanV2ExperimentalProcessing,
173
174 #[doc(hidden)]
176 #[serde(other)]
177 Unknown,
178}
179
180#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
182pub struct FeatureSet(pub BTreeSet<Feature>);
183
184impl FeatureSet {
185 pub fn is_empty(&self) -> bool {
187 self.0.is_empty()
188 }
189
190 pub fn has(&self, feature: Feature) -> bool {
192 self.0.contains(&feature)
193 }
194}
195
196impl FromIterator<Feature> for FeatureSet {
197 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
198 Self(BTreeSet::from_iter(iter))
199 }
200}
201
202impl<'de> Deserialize<'de> for FeatureSet {
203 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
204 where
205 D: serde::Deserializer<'de>,
206 {
207 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
208 set.remove(&Feature::Unknown);
209 Ok(Self(set))
210 }
211}
212
213#[cfg(test)]
214mod tests {
215 use super::*;
216
217 #[test]
218 fn roundtrip() {
219 let features: FeatureSet =
220 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
221 assert_eq!(
222 &features,
223 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
224 );
225 assert_eq!(
226 serde_json::to_string(&features).unwrap(),
227 r#"["organizations:session-replay"]"#
228 );
229 }
230
231 #[test]
232 fn test_continuous_profiling_perfetto_serde() {
233 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
235 assert_eq!(
236 serialized,
237 r#""organizations:continuous-profiling-perfetto""#
238 );
239
240 let deserialized: Feature =
241 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
242 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
243 }
244}