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::DeprecatedOtelTracesEndpoint,
11 Feature::DeprecatedOtelLogsEndpoint,
12 Feature::DeprecatedExtractSpansFromEvent,
13 Feature::DeprecatedStandaloneSpanIngestion,
14 Feature::DeprecatedSpanV2ExperimentalProcessing,
15];
16
17#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
19pub enum Feature {
20 #[serde(rename = "organizations:session-replay")]
24 SessionReplay,
25 #[serde(rename = "organizations:session-replay-recording-scrubbing")]
29 SessionReplayRecordingScrubbing,
30 #[serde(rename = "organizations:session-replay-video-disabled")]
34 SessionReplayVideoDisabled,
35 #[serde(rename = "organizations:profiling")]
39 Profiling,
40 #[serde(rename = "organizations:relay-playstation-ingestion")]
44 PlaystationIngestion,
45 #[serde(rename = "projects:discard-transaction")]
49 DiscardTransaction,
50 #[serde(rename = "organizations:continuous-profiling")]
54 ContinuousProfiling,
55 #[serde(rename = "organizations:continuous-profiling-perfetto")]
62 ContinuousProfilingPerfetto,
63 #[serde(rename = "organizations:ourlogs-ingestion")]
67 OurLogsIngestion,
68 #[serde(rename = "organizations:tracemetrics-ingestion")]
72 TraceMetricsIngestion,
73 #[doc(hidden)]
75 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
76 IngestUnsampledProfiles,
77 #[doc(hidden)]
79 #[serde(rename = "organizations:user-feedback-ingest")]
80 UserReportV2Ingest,
81 #[doc(hidden)]
82 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
83 ViewHierarchyScrubbing,
84 #[serde(rename = "organizations:performance-issues-spans")]
86 PerformanceIssuesSpans,
87 #[serde(rename = "projects:span-v2-attachment-processing")]
89 SpanV2AttachmentProcessing,
90 #[serde(rename = "projects:trace-attachment-processing")]
92 TraceAttachmentProcessing,
93 #[serde(rename = "projects:relay-playstation-uploads")]
95 PlaystationUploads,
96 #[serde(rename = "organizations:relay-unreal-endpoint-expansion")]
99 UnrealEndpointExpansion,
100 #[serde(rename = "projects:relay-minidump-uploads")]
102 MinidumpUploads,
103 #[serde(rename = "projects:relay-upload-multipart")]
107 UploadMultipart,
108 #[serde(rename = "organizations:span-v2-otlp-processing")]
112 DeprecatedSpanV2OtlpProcessing,
113 #[doc(hidden)]
115 #[serde(rename = "projects:span-metrics-extraction")]
116 DeprecatedExtractCommonSpanMetricsFromEvent,
117 #[doc(hidden)]
119 #[serde(rename = "projects:span-metrics-extraction-addons")]
120 DeprecatedExtractAddonsSpanMetricsFromEvent,
121 #[doc(hidden)]
123 #[serde(rename = "organizations:indexed-spans-extraction")]
124 DeprecatedExtractSpansFromEvent,
125 #[doc(hidden)]
129 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
130 DeprecatedOtelTracesEndpoint,
131 #[doc(hidden)]
135 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
136 DeprecatedOtelLogsEndpoint,
137 #[doc(hidden)]
141 #[serde(rename = "organizations:standalone-span-ingestion")]
142 DeprecatedStandaloneSpanIngestion,
143
144 #[doc(hidden)]
148 #[serde(rename = "projects:span-v2-experimental-processing")]
149 DeprecatedSpanV2ExperimentalProcessing,
150
151 #[doc(hidden)]
153 #[serde(other)]
154 Unknown,
155}
156
157#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
159pub struct FeatureSet(pub BTreeSet<Feature>);
160
161impl FeatureSet {
162 pub fn is_empty(&self) -> bool {
164 self.0.is_empty()
165 }
166
167 pub fn has(&self, feature: Feature) -> bool {
169 self.0.contains(&feature)
170 }
171}
172
173impl FromIterator<Feature> for FeatureSet {
174 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
175 Self(BTreeSet::from_iter(iter))
176 }
177}
178
179impl<'de> Deserialize<'de> for FeatureSet {
180 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
181 where
182 D: serde::Deserializer<'de>,
183 {
184 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
185 set.remove(&Feature::Unknown);
186 Ok(Self(set))
187 }
188}
189
190#[cfg(test)]
191mod tests {
192 use super::*;
193
194 #[test]
195 fn roundtrip() {
196 let features: FeatureSet =
197 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
198 assert_eq!(
199 &features,
200 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
201 );
202 assert_eq!(
203 serde_json::to_string(&features).unwrap(),
204 r#"["organizations:session-replay"]"#
205 );
206 }
207
208 #[test]
209 fn test_continuous_profiling_perfetto_serde() {
210 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
212 assert_eq!(
213 serialized,
214 r#""organizations:continuous-profiling-perfetto""#
215 );
216
217 let deserialized: Feature =
218 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
219 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
220 }
221}