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-minidump-uploads")]
94 MinidumpUploads,
95 #[serde(rename = "projects:relay-upload-multipart")]
99 UploadMultipart,
100 #[serde(rename = "organizations:gpu-crash-symbolication")]
103 NvGpuCrashSplit,
104 #[serde(rename = "organizations:span-v2-otlp-processing")]
108 DeprecatedSpanV2OtlpProcessing,
109 #[doc(hidden)]
111 #[serde(rename = "projects:span-metrics-extraction")]
112 DeprecatedExtractCommonSpanMetricsFromEvent,
113 #[doc(hidden)]
115 #[serde(rename = "projects:span-metrics-extraction-addons")]
116 DeprecatedExtractAddonsSpanMetricsFromEvent,
117 #[doc(hidden)]
119 #[serde(rename = "organizations:indexed-spans-extraction")]
120 DeprecatedExtractSpansFromEvent,
121 #[doc(hidden)]
125 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
126 DeprecatedOtelTracesEndpoint,
127 #[doc(hidden)]
131 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
132 DeprecatedOtelLogsEndpoint,
133 #[doc(hidden)]
137 #[serde(rename = "organizations:standalone-span-ingestion")]
138 DeprecatedStandaloneSpanIngestion,
139 #[doc(hidden)]
143 #[serde(rename = "organizations:profiling")]
144 DeprecatedProfiling,
145 #[doc(hidden)]
149 #[serde(rename = "projects:span-v2-experimental-processing")]
150 DeprecatedSpanV2ExperimentalProcessing,
151
152 #[doc(hidden)]
154 #[serde(other)]
155 Unknown,
156}
157
158#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
160pub struct FeatureSet(pub BTreeSet<Feature>);
161
162impl FeatureSet {
163 pub fn is_empty(&self) -> bool {
165 self.0.is_empty()
166 }
167
168 pub fn has(&self, feature: Feature) -> bool {
170 self.0.contains(&feature)
171 }
172}
173
174impl FromIterator<Feature> for FeatureSet {
175 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
176 Self(BTreeSet::from_iter(iter))
177 }
178}
179
180impl<'de> Deserialize<'de> for FeatureSet {
181 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
182 where
183 D: serde::Deserializer<'de>,
184 {
185 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
186 set.remove(&Feature::Unknown);
187 Ok(Self(set))
188 }
189}
190
191#[cfg(test)]
192mod tests {
193 use super::*;
194
195 #[test]
196 fn roundtrip() {
197 let features: FeatureSet =
198 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
199 assert_eq!(
200 &features,
201 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
202 );
203 assert_eq!(
204 serde_json::to_string(&features).unwrap(),
205 r#"["organizations:session-replay"]"#
206 );
207 }
208
209 #[test]
210 fn test_continuous_profiling_perfetto_serde() {
211 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
213 assert_eq!(
214 serialized,
215 r#""organizations:continuous-profiling-perfetto""#
216 );
217
218 let deserialized: Feature =
219 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
220 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
221 }
222}