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