From 9fd1a4310ea7f18a09df9f3a772339a546d6e422 Mon Sep 17 00:00:00 2001 From: Alberto Leal Date: Wed, 16 Jun 2021 12:25:33 -0400 Subject: [PATCH] ref(breakdowns): All fields in breakdown config should be camelCase, and rename the breakdown key name in project options. (#1020) Co-authored-by: Markus Unterwaditzer --- CHANGELOG.md | 6 +++++ .../src/store/normalize/breakdowns.rs | 8 ++++-- relay-server/src/actors/envelopes.rs | 2 +- relay-server/src/actors/project.rs | 4 +-- tests/integration/test_envelope.py | 26 ++++++++++++++++++- 5 files changed, 40 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b6367b9f2..2e6094d4e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +**Internal**: + +- All fields in breakdown config should be camelCase, and rename the breakdown key name in project options. ([#1020](https://github.com/getsentry/relay/pull/1020)) + ## 21.6.1 - No documented changes. diff --git a/relay-general/src/store/normalize/breakdowns.rs b/relay-general/src/store/normalize/breakdowns.rs index 23b8b858af..b233bd2fda 100644 --- a/relay-general/src/store/normalize/breakdowns.rs +++ b/relay-general/src/store/normalize/breakdowns.rs @@ -94,7 +94,7 @@ pub trait EmitBreakdowns { /// Configuration to define breakdowns based on span operation name. #[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] +#[serde(rename_all = "camelCase")] pub struct SpanOperationsConfig { /// Operation names are matched against an array of strings. The match is successful if the span /// operation name starts with any string in the array. If any string in the array has at least @@ -202,15 +202,19 @@ impl EmitBreakdowns for SpanOperationsConfig { /// Configuration to define breakdown to be generated based on properties and breakdown type. #[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "type", rename_all = "snake_case")] +#[serde(tag = "type", rename_all = "camelCase")] pub enum BreakdownConfig { + #[serde(alias = "span_operations")] SpanOperations(SpanOperationsConfig), + #[serde(other)] + Unsupported, } impl EmitBreakdowns for BreakdownConfig { fn emit_breakdowns(&self, event: &Event) -> Option { match self { BreakdownConfig::SpanOperations(config) => config.emit_breakdowns(event), + BreakdownConfig::Unsupported => None, } } } diff --git a/relay-server/src/actors/envelopes.rs b/relay-server/src/actors/envelopes.rs index f806f15455..de135d7c28 100644 --- a/relay-server/src/actors/envelopes.rs +++ b/relay-server/src/actors/envelopes.rs @@ -1173,7 +1173,7 @@ impl EnvelopeProcessor { normalize_user_agent: Some(true), sent_at: envelope.sent_at(), received_at: Some(received_at), - breakdowns: project_state.config.breakdowns.clone(), + breakdowns: project_state.config.breakdowns_v2.clone(), }; let mut store_processor = StoreProcessor::new(store_config, self.geoip_lookup.as_deref()); diff --git a/relay-server/src/actors/project.rs b/relay-server/src/actors/project.rs index 9b48b9a081..f13ee2adf4 100644 --- a/relay-server/src/actors/project.rs +++ b/relay-server/src/actors/project.rs @@ -85,7 +85,7 @@ pub struct ProjectConfig { pub dynamic_sampling: Option, /// Configuration for operation breakdown. Will be emitted only if present. #[serde(skip_serializing_if = "Option::is_none")] - pub breakdowns: Option, + pub breakdowns_v2: Option, /// Exposable features enabled for this project #[serde(skip_serializing_if = "BTreeSet::is_empty")] pub features: BTreeSet, @@ -103,7 +103,7 @@ impl Default for ProjectConfig { event_retention: None, quotas: Vec::new(), dynamic_sampling: None, - breakdowns: None, + breakdowns_v2: None, features: BTreeSet::new(), } } diff --git a/tests/integration/test_envelope.py b/tests/integration/test_envelope.py index 6a66c19f20..b7c308f681 100644 --- a/tests/integration/test_envelope.py +++ b/tests/integration/test_envelope.py @@ -166,17 +166,41 @@ def test_ops_breakdowns(mini_sentry, relay_with_processing, transactions_consume relay = relay_with_processing() config = mini_sentry.add_basic_project_config(42) + config["config"].setdefault( - "breakdowns", + "breakdownsV2", { "span_ops": { "type": "span_operations", "matches": ["http", "db", "browser", "resource"], }, "span_ops_2": { + "type": "spanOperations", + "matches": ["http", "db", "browser", "resource"], + }, + "span_ops_3": { + "type": "whatever", + "matches": ["http", "db", "browser", "resource"], + }, + }, + ) + + config["config"].setdefault( + # old name of span operation breakdown key. we expect these to not generate anything at all + "breakdowns", + { + "span_ops_4": { "type": "span_operations", "matches": ["http", "db", "browser", "resource"], }, + "span_ops_5": { + "type": "spanOperations", + "matches": ["http", "db", "browser", "resource"], + }, + "span_ops_6": { + "type": "whatever", + "matches": ["http", "db", "browser", "resource"], + }, }, )