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 #[doc(hidden)]
71 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
72 IngestUnsampledProfiles,
73 #[doc(hidden)]
75 #[serde(rename = "organizations:user-feedback-ingest")]
76 UserReportV2Ingest,
77 #[doc(hidden)]
78 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
79 ViewHierarchyScrubbing,
80 #[serde(rename = "organizations:performance-issues-spans")]
82 PerformanceIssuesSpans,
83 #[serde(rename = "projects:span-v2-attachment-processing")]
85 SpanV2AttachmentProcessing,
86 #[serde(rename = "projects:trace-attachment-processing")]
88 TraceAttachmentProcessing,
89 #[serde(rename = "projects:relay-playstation-uploads")]
91 PlaystationUploads,
92 #[serde(rename = "projects:relay-nintendo-event-rewrite")]
94 NintendoEventRewrite,
95 #[serde(rename = "projects:relay-minidump-uploads")]
97 MinidumpUploads,
98 #[serde(rename = "organizations:gpu-crash-symbolication")]
101 NvGpuCrashSplit,
102 #[serde(rename = "organizations:span-v2-otlp-processing")]
106 DeprecatedSpanV2OtlpProcessing,
107 #[doc(hidden)]
109 #[serde(rename = "projects:span-metrics-extraction")]
110 DeprecatedExtractCommonSpanMetricsFromEvent,
111 #[doc(hidden)]
113 #[serde(rename = "projects:span-metrics-extraction-addons")]
114 DeprecatedExtractAddonsSpanMetricsFromEvent,
115 #[doc(hidden)]
117 #[serde(rename = "organizations:indexed-spans-extraction")]
118 DeprecatedExtractSpansFromEvent,
119 #[doc(hidden)]
123 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
124 DeprecatedOtelTracesEndpoint,
125 #[doc(hidden)]
129 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
130 DeprecatedOtelLogsEndpoint,
131 #[doc(hidden)]
135 #[serde(rename = "organizations:standalone-span-ingestion")]
136 DeprecatedStandaloneSpanIngestion,
137 #[doc(hidden)]
141 #[serde(rename = "organizations:profiling")]
142 DeprecatedProfiling,
143 #[doc(hidden)]
147 #[serde(rename = "projects:span-v2-experimental-processing")]
148 DeprecatedSpanV2ExperimentalProcessing,
149
150 #[doc(hidden)]
152 #[serde(other)]
153 Unknown,
154}
155
156#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
158pub struct FeatureSet(pub BTreeSet<Feature>);
159
160impl FeatureSet {
161 pub fn is_empty(&self) -> bool {
163 self.0.is_empty()
164 }
165
166 pub fn has(&self, feature: Feature) -> bool {
168 self.0.contains(&feature)
169 }
170}
171
172impl FromIterator<Feature> for FeatureSet {
173 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
174 Self(BTreeSet::from_iter(iter))
175 }
176}
177
178impl<'de> Deserialize<'de> for FeatureSet {
179 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
180 where
181 D: serde::Deserializer<'de>,
182 {
183 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
184 set.remove(&Feature::Unknown);
185 Ok(Self(set))
186 }
187}
188
189#[cfg(test)]
190mod tests {
191 use super::*;
192
193 #[test]
194 fn roundtrip() {
195 let features: FeatureSet =
196 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
197 assert_eq!(
198 &features,
199 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
200 );
201 assert_eq!(
202 serde_json::to_string(&features).unwrap(),
203 r#"["organizations:session-replay"]"#
204 );
205 }
206
207 #[test]
208 fn test_continuous_profiling_perfetto_serde() {
209 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
211 assert_eq!(
212 serialized,
213 r#""organizations:continuous-profiling-perfetto""#
214 );
215
216 let deserialized: Feature =
217 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
218 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
219 }
220}