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:custom-metrics")]
38 CustomMetrics,
39 #[serde(rename = "organizations:profiling")]
43 Profiling,
44 #[serde(rename = "organizations:relay-playstation-ingestion")]
48 PlaystationIngestion,
49 #[serde(rename = "projects:discard-transaction")]
53 DiscardTransaction,
54 #[serde(rename = "organizations:continuous-profiling")]
58 ContinuousProfiling,
59 #[serde(rename = "organizations:continuous-profiling-perfetto")]
66 ContinuousProfilingPerfetto,
67 #[serde(rename = "organizations:ourlogs-ingestion")]
71 OurLogsIngestion,
72 #[serde(rename = "organizations:tracemetrics-ingestion")]
76 TraceMetricsIngestion,
77 #[doc(hidden)]
79 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
80 IngestUnsampledProfiles,
81 #[doc(hidden)]
83 #[serde(rename = "organizations:user-feedback-ingest")]
84 UserReportV2Ingest,
85 #[doc(hidden)]
86 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
87 ViewHierarchyScrubbing,
88 #[serde(rename = "organizations:performance-issues-spans")]
90 PerformanceIssuesSpans,
91 #[serde(rename = "projects:span-v2-experimental-processing")]
93 SpanV2ExperimentalProcessing,
94 #[serde(rename = "projects:span-v2-attachment-processing")]
96 SpanV2AttachmentProcessing,
97 #[serde(rename = "projects:trace-attachment-processing")]
99 TraceAttachmentProcessing,
100 #[serde(rename = "projects:relay-playstation-uploads")]
102 PlaystationUploads,
103 #[serde(rename = "organizations:relay-unreal-endpoint-expansion")]
106 UnrealEndpointExpansion,
107 #[serde(rename = "projects:relay-minidump-attachment-uploads")]
109 MinidumpAttachmentUploads,
110 #[serde(rename = "projects:relay-minidump-uploads")]
112 MinidumpUploads,
113 #[serde(rename = "projects:minidump-multi-exception")]
115 MinidumpMultiException,
116 #[serde(rename = "organizations:relay-generate-billing-outcome")]
118 GenerateBillingOutcome,
119
120 #[serde(rename = "organizations:span-v2-otlp-processing")]
124 DeprecatedSpanV2OtlpProcessing,
125 #[doc(hidden)]
127 #[serde(rename = "projects:span-metrics-extraction")]
128 DeprecatedExtractCommonSpanMetricsFromEvent,
129 #[doc(hidden)]
131 #[serde(rename = "projects:span-metrics-extraction-addons")]
132 DeprecatedExtractAddonsSpanMetricsFromEvent,
133 #[doc(hidden)]
135 #[serde(rename = "organizations:indexed-spans-extraction")]
136 DeprecatedExtractSpansFromEvent,
137 #[doc(hidden)]
141 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
142 DeprecatedOtelTracesEndpoint,
143 #[doc(hidden)]
147 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
148 DeprecatedOtelLogsEndpoint,
149 #[doc(hidden)]
153 #[serde(rename = "organizations:standalone-span-ingestion")]
154 DeprecatedStandaloneSpanIngestion,
155
156 #[doc(hidden)]
158 #[serde(other)]
159 Unknown,
160}
161
162#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
164pub struct FeatureSet(pub BTreeSet<Feature>);
165
166impl FeatureSet {
167 pub fn is_empty(&self) -> bool {
169 self.0.is_empty()
170 }
171
172 pub fn has(&self, feature: Feature) -> bool {
174 self.0.contains(&feature)
175 }
176}
177
178impl FromIterator<Feature> for FeatureSet {
179 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
180 Self(BTreeSet::from_iter(iter))
181 }
182}
183
184impl<'de> Deserialize<'de> for FeatureSet {
185 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
186 where
187 D: serde::Deserializer<'de>,
188 {
189 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
190 set.remove(&Feature::Unknown);
191 Ok(Self(set))
192 }
193}
194
195#[cfg(test)]
196mod tests {
197 use super::*;
198
199 #[test]
200 fn roundtrip() {
201 let features: FeatureSet =
202 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
203 assert_eq!(
204 &features,
205 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
206 );
207 assert_eq!(
208 serde_json::to_string(&features).unwrap(),
209 r#"["organizations:session-replay"]"#
210 );
211 }
212
213 #[test]
214 fn test_continuous_profiling_perfetto_serde() {
215 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
217 assert_eq!(
218 serialized,
219 r#""organizations:continuous-profiling-perfetto""#
220 );
221
222 let deserialized: Feature =
223 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
224 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
225 }
226}