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::DeprecatedExtractSpansFromEvent,
11 Feature::DeprecatedStandaloneSpanIngestion,
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:custom-metrics")]
36 CustomMetrics,
37 #[serde(rename = "organizations:profiling")]
41 Profiling,
42 #[serde(rename = "organizations:relay-otlp-traces-endpoint")]
46 OtelTracesEndpoint,
47 #[serde(rename = "organizations:relay-otel-logs-endpoint")]
51 OtelLogsEndpoint,
52 #[serde(rename = "organizations:relay-playstation-ingestion")]
56 PlaystationIngestion,
57 #[serde(rename = "projects:discard-transaction")]
61 DiscardTransaction,
62 #[serde(rename = "organizations:continuous-profiling")]
66 ContinuousProfiling,
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-default-trace-id")]
108 AddDefaultTraceID,
109 #[serde(rename = "organizations:relay-unreal-endpoint-expansion")]
112 UnrealEndpointExpansion,
113
114 #[serde(rename = "organizations:span-v2-otlp-processing")]
118 DeprecatedSpanV2OtlpProcessing,
119 #[doc(hidden)]
121 #[serde(rename = "projects:span-metrics-extraction")]
122 DeprecatedExtractCommonSpanMetricsFromEvent,
123 #[doc(hidden)]
125 #[serde(rename = "projects:span-metrics-extraction-addons")]
126 DeprecatedExtractAddonsSpanMetricsFromEvent,
127 #[doc(hidden)]
129 #[serde(rename = "organizations:indexed-spans-extraction")]
130 DeprecatedExtractSpansFromEvent,
131 #[doc(hidden)]
135 #[serde(rename = "organizations:standalone-span-ingestion")]
136 DeprecatedStandaloneSpanIngestion,
137
138 #[doc(hidden)]
140 #[serde(other)]
141 Unknown,
142}
143
144#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize)]
146pub struct FeatureSet(pub BTreeSet<Feature>);
147
148impl FeatureSet {
149 pub fn is_empty(&self) -> bool {
151 self.0.is_empty()
152 }
153
154 pub fn has(&self, feature: Feature) -> bool {
156 self.0.contains(&feature)
157 }
158}
159
160impl FromIterator<Feature> for FeatureSet {
161 fn from_iter<T: IntoIterator<Item = Feature>>(iter: T) -> Self {
162 Self(BTreeSet::from_iter(iter))
163 }
164}
165
166impl<'de> Deserialize<'de> for FeatureSet {
167 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
168 where
169 D: serde::Deserializer<'de>,
170 {
171 let mut set = BTreeSet::<Feature>::deserialize(deserializer)?;
172 set.remove(&Feature::Unknown);
173 Ok(Self(set))
174 }
175}
176
177#[cfg(test)]
178mod tests {
179 use super::*;
180
181 #[test]
182 fn roundtrip() {
183 let features: FeatureSet =
184 serde_json::from_str(r#"["organizations:session-replay", "foo"]"#).unwrap();
185 assert_eq!(
186 &features,
187 &FeatureSet(BTreeSet::from([Feature::SessionReplay]))
188 );
189 assert_eq!(
190 serde_json::to_string(&features).unwrap(),
191 r#"["organizations:session-replay"]"#
192 );
193 }
194}