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];
15
16#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
18pub enum Feature {
19 #[serde(rename = "organizations:session-replay")]
23 SessionReplay,
24 #[serde(rename = "organizations:session-replay-recording-scrubbing")]
28 SessionReplayRecordingScrubbing,
29 #[serde(rename = "organizations:session-replay-video-disabled")]
33 SessionReplayVideoDisabled,
34 #[serde(rename = "organizations:profiling")]
38 Profiling,
39 #[serde(rename = "organizations:relay-playstation-ingestion")]
43 PlaystationIngestion,
44 #[serde(rename = "projects:discard-transaction")]
48 DiscardTransaction,
49 #[serde(rename = "organizations:continuous-profiling")]
53 ContinuousProfiling,
54 #[serde(rename = "organizations:continuous-profiling-perfetto")]
61 ContinuousProfilingPerfetto,
62 #[serde(rename = "organizations:ourlogs-ingestion")]
66 OurLogsIngestion,
67 #[serde(rename = "organizations:tracemetrics-ingestion")]
71 TraceMetricsIngestion,
72 #[doc(hidden)]
74 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
75 IngestUnsampledProfiles,
76 #[doc(hidden)]
78 #[serde(rename = "organizations:user-feedback-ingest")]
79 UserReportV2Ingest,
80 #[doc(hidden)]
81 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
82 ViewHierarchyScrubbing,
83 #[serde(rename = "organizations:performance-issues-spans")]
85 PerformanceIssuesSpans,
86 #[serde(rename = "projects:span-v2-experimental-processing")]
88 SpanV2ExperimentalProcessing,
89 #[serde(rename = "projects:span-v2-attachment-processing")]
91 SpanV2AttachmentProcessing,
92 #[serde(rename = "projects:trace-attachment-processing")]
94 TraceAttachmentProcessing,
95 #[serde(rename = "projects:relay-playstation-uploads")]
97 PlaystationUploads,
98 #[serde(rename = "organizations:relay-unreal-endpoint-expansion")]
101 UnrealEndpointExpansion,
102 #[serde(rename = "projects:relay-minidump-attachment-uploads")]
104 MinidumpAttachmentUploads,
105 #[serde(rename = "projects:relay-minidump-uploads")]
107 MinidumpUploads,
108 #[serde(rename = "projects:minidump-multi-exception")]
110 MinidumpMultiException,
111 #[serde(rename = "organizations:relay-generate-billing-outcome")]
113 GenerateBillingOutcome,
114
115 #[serde(rename = "organizations:span-v2-otlp-processing")]
119 DeprecatedSpanV2OtlpProcessing,
120 #[doc(hidden)]
122 #[serde(rename = "projects:span-metrics-extraction")]
123 DeprecatedExtractCommonSpanMetricsFromEvent,
124 #[doc(hidden)]
126 #[serde(rename = "projects:span-metrics-extraction-addons")]
127 DeprecatedExtractAddonsSpanMetricsFromEvent,
128 #[doc(hidden)]
130 #[serde(rename = "organizations:indexed-spans-extraction")]
131 DeprecatedExtractSpansFromEvent,
132 #[doc(hidden)]
136 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
137 DeprecatedOtelTracesEndpoint,
138 #[doc(hidden)]
142 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
143 DeprecatedOtelLogsEndpoint,
144 #[doc(hidden)]
148 #[serde(rename = "organizations:standalone-span-ingestion")]
149 DeprecatedStandaloneSpanIngestion,
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}