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::ScrubMongoDbDescriptions,
11 Feature::DeprecatedExtractSpansFromEvent,
12];
13
14#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
16pub enum Feature {
17 #[serde(rename = "organizations:session-replay")]
21 SessionReplay,
22 #[serde(rename = "organizations:session-replay-recording-scrubbing")]
26 SessionReplayRecordingScrubbing,
27 #[serde(rename = "organizations:session-replay-video-disabled")]
31 SessionReplayVideoDisabled,
32 #[serde(rename = "organizations:device-class-synthesis")]
38 DeviceClassSynthesis,
39 #[serde(rename = "organizations:custom-metrics")]
43 CustomMetrics,
44 #[serde(rename = "organizations:profiling")]
48 Profiling,
49 #[serde(rename = "organizations:standalone-span-ingestion")]
53 StandaloneSpanIngestion,
54 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
58 OtelTracesEndpoint,
59 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
63 OtelLogsEndpoint,
64 #[serde(rename = "organizations:relay-playstation-ingestion")]
68 PlaystationIngestion,
69 #[serde(rename = "projects:discard-transaction")]
73 DiscardTransaction,
74 #[serde(rename = "organizations:continuous-profiling")]
78 ContinuousProfiling,
79 #[serde(rename = "organizations:continuous-profiling-beta")]
83 ContinuousProfilingBeta,
84 #[serde(rename = "organizations:continuous-profiling-beta-ingest")]
88 ContinuousProfilingBetaIngest,
89 #[serde(rename = "organizations:ourlogs-ingestion")]
93 OurLogsIngestion,
94 #[serde(rename = "organizations:tracemetrics-ingestion")]
98 TraceMetricsIngestion,
99 #[doc(hidden)]
101 #[serde(rename = "projects:profiling-ingest-unsampled-profiles")]
102 IngestUnsampledProfiles,
103 #[doc(hidden)]
105 #[serde(rename = "organizations:user-feedback-ingest")]
106 UserReportV2Ingest,
107 #[doc(hidden)]
109 #[serde(rename = "organizations:performance-queries-mongodb-extraction")]
110 ScrubMongoDbDescriptions,
111 #[doc(hidden)]
112 #[serde(rename = "organizations:view-hierarchy-scrubbing")]
113 ViewHierarchyScrubbing,
114 #[serde(rename = "organizations:performance-issues-spans")]
116 PerformanceIssuesSpans,
117 #[serde(rename = "projects:span-v2-experimental-processing")]
119 SpanV2ExperimentalProcessing,
120 #[serde(rename = "projects:span-v2-attachment-processing")]
122 SpanV2AttachmentProcessing,
123 #[serde(rename = "projects:trace-attachment-processing")]
125 TraceAttachmentProcessing,
126 #[serde(rename = "projects:relay-upload-endpoint")]
128 UploadEndpoint,
129 #[serde(rename = "organizations:relay-new-error-processing")]
131 NewErrorProcessing,
132 #[serde(rename = "organizations:new-client-report-processing")]
134 NewClientReportProcessing,
135
136 #[serde(rename = "organizations:span-v2-otlp-processing")]
140 DeprecatedSpanV2OtlpProcessing,
141 #[doc(hidden)]
143 #[serde(rename = "projects:span-metrics-extraction")]
144 DeprecatedExtractCommonSpanMetricsFromEvent,
145 #[doc(hidden)]
147 #[serde(rename = "projects:span-metrics-extraction-addons")]
148 DeprecatedExtractAddonsSpanMetricsFromEvent,
149 #[doc(hidden)]
151 #[serde(rename = "organizations:indexed-spans-extraction")]
152 DeprecatedExtractSpansFromEvent,
153 #[doc(hidden)]
155 #[serde(other)]
156 Unknown,
157}
158
159#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
161pub struct FeatureSet(pub BTreeSet<Feature>);
162
163impl FeatureSet {
164 pub fn is_empty(&self) -> bool {
166 self.0.is_empty()
167 }
168
169 pub fn has(&self, feature: Feature) -> bool {
171 self.0.contains(&feature)
172 }
173}
174
175impl FromIterator<Feature> for FeatureSet {
176 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
177 Self(BTreeSet::from_iter(iter))
178 }
179}
180
181impl<'de> Deserialize<'de> for FeatureSet {
182 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
183 where
184 D: serde::Deserializer<'de>,
185 {
186 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
187 set.remove(&Feature::Unknown);
188 Ok(Self(set))
189 }
190}
191
192#[cfg(test)]
193mod tests {
194 use super::*;
195
196 #[test]
197 fn roundtrip() {
198 let features: FeatureSet =
199 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
200 assert_eq!(
201 &features,
202 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
203 );
204 assert_eq!(
205 serde_json::to_string(&features).unwrap(),
206 r#"["organizations:session-replay"]"#
207 );
208 }
209}