From 27b694be3eaabaedfb8af7c8cc9595d4e4871d0e Mon Sep 17 00:00:00 2001 From: Evan Hicks Date: Fri, 22 Mar 2024 10:15:42 -0400 Subject: [PATCH 1/4] feat(meta): Add record_meta field to counters consumer This field will be used by the materialized view to determine whether the row should be processed into the meta table. --- rust_snuba/src/processors/generic_metrics.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/rust_snuba/src/processors/generic_metrics.rs b/rust_snuba/src/processors/generic_metrics.rs index f7fa30b9cb..fc64c4abe1 100644 --- a/rust_snuba/src/processors/generic_metrics.rs +++ b/rust_snuba/src/processors/generic_metrics.rs @@ -172,6 +172,8 @@ struct CountersRawRow { common_fields: CommonMetricFields, #[serde(default)] count_value: f64, + #[serde(skip_serializing_if = "Option::is_none")] + record_meta: Option, } /// Parse is the trait which should be implemented for all metric types. @@ -210,6 +212,15 @@ impl Parse for CountersRawRow { } let retention_days = enforce_retention(Some(from.retention_days), &config.env_config); + let mut record_meta: Option = Some(1); + let blacklisted_use_case_ids = vec!["escalating_issues", "metric_stats"]; + if blacklisted_use_case_ids + .iter() + .any(|&u| u == from.use_case_id) + { + record_meta = Some(0); + } + let common_fields = CommonMetricFields { use_case_id: from.use_case_id, org_id: from.org_id, @@ -230,6 +241,7 @@ impl Parse for CountersRawRow { Ok(Some(Self { common_fields, count_value, + record_meta, })) } } @@ -726,6 +738,7 @@ mod tests { day_retention_days: None, }, count_value: 1.0, + record_meta: Some(1), }; assert_eq!( result.unwrap(), From 0ffb93dd4ebf62c7b62068a8b43a98d0ad71f214 Mon Sep 17 00:00:00 2001 From: Evan Hicks Date: Fri, 22 Mar 2024 11:21:20 -0400 Subject: [PATCH 2/4] fix linting --- rust_snuba/src/processors/generic_metrics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust_snuba/src/processors/generic_metrics.rs b/rust_snuba/src/processors/generic_metrics.rs index fc64c4abe1..ac28e4ad54 100644 --- a/rust_snuba/src/processors/generic_metrics.rs +++ b/rust_snuba/src/processors/generic_metrics.rs @@ -213,7 +213,7 @@ impl Parse for CountersRawRow { let retention_days = enforce_retention(Some(from.retention_days), &config.env_config); let mut record_meta: Option = Some(1); - let blacklisted_use_case_ids = vec!["escalating_issues", "metric_stats"]; + let blacklisted_use_case_ids = ["escalating_issues", "metric_stats"]; if blacklisted_use_case_ids .iter() .any(|&u| u == from.use_case_id) From 80268b5fe6560ff4e9f9bcff9d1b6265522393c6 Mon Sep 17 00:00:00 2001 From: Evan Hicks Date: Fri, 22 Mar 2024 12:55:56 -0400 Subject: [PATCH 3/4] use a match statement --- rust_snuba/src/processors/generic_metrics.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/rust_snuba/src/processors/generic_metrics.rs b/rust_snuba/src/processors/generic_metrics.rs index ac28e4ad54..010e731ef5 100644 --- a/rust_snuba/src/processors/generic_metrics.rs +++ b/rust_snuba/src/processors/generic_metrics.rs @@ -212,14 +212,11 @@ impl Parse for CountersRawRow { } let retention_days = enforce_retention(Some(from.retention_days), &config.env_config); - let mut record_meta: Option = Some(1); - let blacklisted_use_case_ids = ["escalating_issues", "metric_stats"]; - if blacklisted_use_case_ids - .iter() - .any(|&u| u == from.use_case_id) - { - record_meta = Some(0); - } + let record_meta = match from.use_case_id.as_str() { + "escalating_issues" => Some(0), + "metric_stats" => Some(0), + _ => Some(1), + }; let common_fields = CommonMetricFields { use_case_id: from.use_case_id, From 9a6b53d175252dcd455129b19ab7ca051112caee Mon Sep 17 00:00:00 2001 From: Evan Hicks Date: Mon, 25 Mar 2024 12:02:35 -0400 Subject: [PATCH 4/4] update snapshot --- ...or-snuba-generic-metrics__1__snuba-generic-metrics1.json.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/rust_snuba/src/processors/snapshots/rust_snuba__processors__tests__schemas@snuba-generic-metrics-GenericCountersMetricsProcessor-snuba-generic-metrics__1__snuba-generic-metrics1.json.snap b/rust_snuba/src/processors/snapshots/rust_snuba__processors__tests__schemas@snuba-generic-metrics-GenericCountersMetricsProcessor-snuba-generic-metrics__1__snuba-generic-metrics1.json.snap index f701204a04..99b76ee498 100644 --- a/rust_snuba/src/processors/snapshots/rust_snuba__processors__tests__schemas@snuba-generic-metrics-GenericCountersMetricsProcessor-snuba-generic-metrics__1__snuba-generic-metrics1.json.snap +++ b/rust_snuba/src/processors/snapshots/rust_snuba__processors__tests__schemas@snuba-generic-metrics-GenericCountersMetricsProcessor-snuba-generic-metrics__1__snuba-generic-metrics1.json.snap @@ -17,6 +17,7 @@ expression: snapshot_payload "min_retention_days": 90, "org_id": 1, "project_id": 3, + "record_meta": 1, "retention_days": 90, "tags.indexed_value": [ 0,