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