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-uploads")]
104 MinidumpUploads,
105 #[serde(rename = "projects:relay-upload-multipart")]
109 UploadMultipart,
110 #[serde(rename = "organizations:span-v2-otlp-processing")]
114 DeprecatedSpanV2OtlpProcessing,
115 #[doc(hidden)]
117 #[serde(rename = "projects:span-metrics-extraction")]
118 DeprecatedExtractCommonSpanMetricsFromEvent,
119 #[doc(hidden)]
121 #[serde(rename = "projects:span-metrics-extraction-addons")]
122 DeprecatedExtractAddonsSpanMetricsFromEvent,
123 #[doc(hidden)]
125 #[serde(rename = "organizations:indexed-spans-extraction")]
126 DeprecatedExtractSpansFromEvent,
127 #[doc(hidden)]
131 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
132 DeprecatedOtelTracesEndpoint,
133 #[doc(hidden)]
137 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
138 DeprecatedOtelLogsEndpoint,
139 #[doc(hidden)]
143 #[serde(rename = "organizations:standalone-span-ingestion")]
144 DeprecatedStandaloneSpanIngestion,
145
146 #[doc(hidden)]
148 #[serde(other)]
149 Unknown,
150}
151
152#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
154pub struct FeatureSet(pub BTreeSet<Feature>);
155
156impl FeatureSet {
157 pub fn is_empty(&self) -> bool {
159 self.0.is_empty()
160 }
161
162 pub fn has(&self, feature: Feature) -> bool {
164 self.0.contains(&feature)
165 }
166}
167
168impl FromIterator<Feature> for FeatureSet {
169 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
170 Self(BTreeSet::from_iter(iter))
171 }
172}
173
174impl<'de> Deserialize<'de> for FeatureSet {
175 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
176 where
177 D: serde::Deserializer<'de>,
178 {
179 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
180 set.remove(&Feature::Unknown);
181 Ok(Self(set))
182 }
183}
184
185#[cfg(test)]
186mod tests {
187 use super::*;
188
189 #[test]
190 fn roundtrip() {
191 let features: FeatureSet =
192 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
193 assert_eq!(
194 &features,
195 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
196 );
197 assert_eq!(
198 serde_json::to_string(&features).unwrap(),
199 r#"["organizations:session-replay"]"#
200 );
201 }
202
203 #[test]
204 fn test_continuous_profiling_perfetto_serde() {
205 let serialized = serde_json::to_string(&Feature::ContinuousProfilingPerfetto).unwrap();
207 assert_eq!(
208 serialized,
209 r#""organizations:continuous-profiling-perfetto""#
210 );
211
212 let deserialized: Feature =
213 serde_json::from_str(r#""organizations:continuous-profiling-perfetto""#).unwrap();
214 assert_eq!(deserialized, Feature::ContinuousProfilingPerfetto);
215 }
216}