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-upload-endpoint")]
102 UploadEndpoint,
103 #[serde(rename = "projects:relay-playstation-uploads")]
105 PlaystationUploads,
106 #[serde(rename = "organizations:relay-unreal-endpoint-expansion")]
109 UnrealEndpointExpansion,
110 #[serde(rename = "projects:relay-minidump-attachment-uploads")]
112 MinidumpAttachmentUploads,
113 #[serde(rename = "projects:relay-minidump-uploads")]
115 MinidumpUploads,
116 #[serde(rename = "projects:minidump-multi-exception")]
118 MinidumpMultiException,
119 #[serde(rename = "organizations:relay-generate-billing-outcome")]
121 GenerateBillingOutcome,
122
123 #[serde(rename = "organizations:span-v2-otlp-processing")]
127 DeprecatedSpanV2OtlpProcessing,
128 #[doc(hidden)]
130 #[serde(rename = "projects:span-metrics-extraction")]
131 DeprecatedExtractCommonSpanMetricsFromEvent,
132 #[doc(hidden)]
134 #[serde(rename = "projects:span-metrics-extraction-addons")]
135 DeprecatedExtractAddonsSpanMetricsFromEvent,
136 #[doc(hidden)]
138 #[serde(rename = "organizations:indexed-spans-extraction")]
139 DeprecatedExtractSpansFromEvent,
140 #[doc(hidden)]
144 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
145 DeprecatedOtelTracesEndpoint,
146 #[doc(hidden)]
150 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
151 DeprecatedOtelLogsEndpoint,
152 #[doc(hidden)]
156 #[serde(rename = "organizations:standalone-span-ingestion")]
157 DeprecatedStandaloneSpanIngestion,
158
159 #[doc(hidden)]
161 #[serde(other)]
162 Unknown,
163}
164
165#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
167pub struct FeatureSet(pub BTreeSet<Feature>);
168
169impl FeatureSet {
170 pub fn is_empty(&self) -> bool {
172 self.0.is_empty()
173 }
174
175 pub fn has(&self, feature: Feature) -> bool {
177 self.0.contains(&feature)
178 }
179}
180
181impl FromIterator<Feature> for FeatureSet {
182 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
183 Self(BTreeSet::from_iter(iter))
184 }
185}
186
187impl<'de> Deserialize<'de> for FeatureSet {
188 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
189 where
190 D: serde::Deserializer<'de>,
191 {
192 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
193 set.remove(&Feature::Unknown);
194 Ok(Self(set))
195 }
196}
197
198#[cfg(test)]
199mod tests {
200 use super::*;
201
202 #[test]
203 fn roundtrip() {
204 let features: FeatureSet =
205 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
206 assert_eq!(
207 &features,
208 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
209 );
210 assert_eq!(
211 serde_json::to_string(&features).unwrap(),
212 r#"["organizations:session-replay"]"#
213 );
214 }
215
216 #[test]
217 fn test_continuous_profiling_perfetto_serde() {
218 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
220 assert_eq!(
221 serialized,
222 r#""organizations:continuous-profiling-perfetto""#
223 );
224
225 let deserialized: Feature =
226 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
227 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
228 }
229}