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 #[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 #[serde(rename = "projects:span-v2-attachment-processing")]
134 SpanV2AttachmentProcessing,
135 #[doc(hidden)]
137 #[serde(other)]
138 Unknown,
139}
140
141#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
143pub struct FeatureSet(pub BTreeSet<Feature>);
144
145impl FeatureSet {
146 pub fn is_empty(&self) -> bool {
148 self.0.is_empty()
149 }
150
151 pub fn has(&self, feature: Feature) -> bool {
153 self.0.contains(&feature)
154 }
155}
156
157impl FromIterator<Feature> for FeatureSet {
158 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
159 Self(BTreeSet::from_iter(iter))
160 }
161}
162
163impl<'de> Deserialize<'de> for FeatureSet {
164 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
165 where
166 D: serde::Deserializer<'de>,
167 {
168 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
169 set.remove(&Feature::Unknown);
170 Ok(Self(set))
171 }
172}
173
174#[cfg(test)]
175mod tests {
176 use super::*;
177
178 #[test]
179 fn roundtrip() {
180 let features: FeatureSet =
181 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
182 assert_eq!(
183 &features,
184 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
185 );
186 assert_eq!(
187 serde_json::to_string(&features).unwrap(),
188 r#"["organizations:session-replay"]"#
189 );
190 }
191}