diff --git a/CHANGELOG.md b/CHANGELOG.md index 95467ade115..34f4f4a229b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ **Internal**: -- Remove metrics summaries. ([#4278](https://github.com/getsentry/relay/pull/4278)) +- Remove metrics summaries. ([#4278](https://github.com/getsentry/relay/pull/4278), [#4279](https://github.com/getsentry/relay/pull/4279)) ## 24.11.0 diff --git a/relay-event-normalization/src/event.rs b/relay-event-normalization/src/event.rs index 9d8be0636c0..bb04d466b54 100644 --- a/relay-event-normalization/src/event.rs +++ b/relay-event-normalization/src/event.rs @@ -11,18 +11,17 @@ use std::sync::OnceLock; use itertools::Itertools; use regex::Regex; use relay_base_schema::metrics::{ - can_be_valid_metric_name, DurationUnit, FractionUnit, MetricResourceIdentifier, MetricUnit, + can_be_valid_metric_name, DurationUnit, FractionUnit, MetricUnit, }; use relay_event_schema::processor::{self, ProcessingAction, ProcessingState, Processor}; use relay_event_schema::protocol::{ AsPair, ClientSdkInfo, Context, ContextInner, Contexts, DebugImage, DeviceClass, Event, EventId, EventType, Exception, Headers, IpAddr, Level, LogEntry, Measurement, Measurements, - MetricSummaryMapping, NelContext, PerformanceScoreContext, ReplayContext, Request, Span, - SpanStatus, Tags, Timestamp, TraceContext, User, VALID_PLATFORMS, + NelContext, PerformanceScoreContext, ReplayContext, Request, Span, SpanStatus, Tags, Timestamp, + TraceContext, User, VALID_PLATFORMS, }; use relay_protocol::{ - Annotated, Empty, Error, ErrorKind, FromValue, Getter, IntoValue, Meta, Object, Remark, - RemarkType, Value, + Annotated, Empty, Error, ErrorKind, FromValue, Getter, Meta, Object, Remark, RemarkType, Value, }; use smallvec::SmallVec; use uuid::Uuid; @@ -330,7 +329,6 @@ fn normalize(event: &mut Event, meta: &mut Meta, config: &NormalizationConfig) { if config.normalize_spans && event.ty.value() == Some(&EventType::Transaction) { crate::normalize::normalize_app_start_spans(event); span::exclusive_time::compute_span_exclusive_time(event); - normalize_all_metrics_summaries(event); } if config.enrich_spans { @@ -347,45 +345,6 @@ fn normalize(event: &mut Event, meta: &mut Meta, config: &NormalizationConfig) { normalize_replay_context(event, config.replay_id); } -/// Normalizes all the metrics summaries across the event payload. -fn normalize_all_metrics_summaries(event: &mut Event) { - if let Some(metrics_summary) = event._metrics_summary.value_mut().as_mut() { - metrics_summary.update_value(normalize_metrics_summary_mris); - } - - let Some(spans) = event.spans.value_mut() else { - return; - }; - - for span in spans.iter_mut() { - let metrics_summary = span - .value_mut() - .as_mut() - .and_then(|span| span._metrics_summary.value_mut().as_mut()); - - if let Some(ms) = metrics_summary { - ms.update_value(normalize_metrics_summary_mris); - } - } -} - -/// Replaces all incoming metric identifiers in the metric summary with the correct MRI. -/// -/// The reasoning behind this normalization, is that the SDK sends namespace-agnostic metric -/// identifiers in the form `metric_type:metric_name@metric_unit` and those identifiers need to be -/// converted to MRIs in the form `metric_type:metric_namespace/metric_name@metric_unit`. -fn normalize_metrics_summary_mris(m: MetricSummaryMapping) -> MetricSummaryMapping { - m.into_iter() - .map(|(key, value)| match MetricResourceIdentifier::parse(&key) { - Ok(mri) => (mri.to_string(), value), - Err(err) => ( - key, - Annotated::from_error(Error::invalid(err), value.0.map(IntoValue::into_value)), - ), - }) - .collect() -} - fn normalize_replay_context(event: &mut Event, replay_id: Option) { if let Some(ref mut contexts) = event.contexts.value_mut() { if let Some(replay_id) = replay_id { @@ -1485,12 +1444,10 @@ mod tests { use std::collections::BTreeMap; - use insta::{assert_debug_snapshot, assert_json_snapshot}; + use insta::assert_debug_snapshot; use itertools::Itertools; use relay_common::glob2::LazyGlob; - use relay_event_schema::protocol::{ - Breadcrumb, Csp, DebugMeta, DeviceContext, MetricSummary, MetricsSummary, Span, Values, - }; + use relay_event_schema::protocol::{Breadcrumb, Csp, DebugMeta, DeviceContext, Values}; use relay_protocol::{get_value, SerializableAnnotated}; use serde_json::json; @@ -4110,173 +4067,6 @@ mod tests { }"#); } - #[test] - fn test_normalize_metrics_summary_metric_identifiers() { - let mut metric_tags = BTreeMap::new(); - metric_tags.insert( - "transaction".to_string(), - Annotated::new("/hello".to_string()), - ); - - let metric_summary = vec![Annotated::new(MetricSummary { - min: Annotated::new(1.0), - max: Annotated::new(20.0), - sum: Annotated::new(21.0), - count: Annotated::new(2), - tags: Annotated::new(metric_tags), - })]; - - let mut metrics_summary = BTreeMap::new(); - metrics_summary.insert( - "d:page_duration@millisecond".to_string(), - Annotated::new(metric_summary.clone()), - ); - metrics_summary.insert( - "c:custom/page_click@none".to_string(), - Annotated::new(Default::default()), - ); - metrics_summary.insert( - "s:user@none".to_string(), - Annotated::new(metric_summary.clone()), - ); - metrics_summary.insert("invalid".to_string(), Annotated::new(metric_summary)); - metrics_summary.insert( - "g:page_load@second".to_string(), - Annotated::new(Default::default()), - ); - let metrics_summary = MetricsSummary(metrics_summary); - - let mut event = Annotated::new(Event { - spans: Annotated::new(vec![Annotated::new(Span { - op: Annotated::new("my_span".to_owned()), - _metrics_summary: Annotated::new(metrics_summary.clone()), - ..Default::default() - })]), - _metrics_summary: Annotated::new(metrics_summary), - ..Default::default() - }); - normalize_all_metrics_summaries(event.value_mut().as_mut().unwrap()); - assert_json_snapshot!(SerializableAnnotated(&event), @r###" - { - "spans": [ - { - "op": "my_span", - "_metrics_summary": { - "c:custom/page_click@none": [], - "d:custom/page_duration@millisecond": [ - { - "min": 1.0, - "max": 20.0, - "sum": 21.0, - "count": 2, - "tags": { - "transaction": "/hello" - } - } - ], - "g:custom/page_load@second": [], - "invalid": null, - "s:custom/user@none": [ - { - "min": 1.0, - "max": 20.0, - "sum": 21.0, - "count": 2, - "tags": { - "transaction": "/hello" - } - } - ] - } - } - ], - "_metrics_summary": { - "c:custom/page_click@none": [], - "d:custom/page_duration@millisecond": [ - { - "min": 1.0, - "max": 20.0, - "sum": 21.0, - "count": 2, - "tags": { - "transaction": "/hello" - } - } - ], - "g:custom/page_load@second": [], - "invalid": null, - "s:custom/user@none": [ - { - "min": 1.0, - "max": 20.0, - "sum": 21.0, - "count": 2, - "tags": { - "transaction": "/hello" - } - } - ] - }, - "_meta": { - "_metrics_summary": { - "invalid": { - "": { - "err": [ - [ - "invalid_data", - { - "reason": "failed to parse metric" - } - ] - ], - "val": [ - { - "count": 2, - "max": 20.0, - "min": 1.0, - "sum": 21.0, - "tags": { - "transaction": "/hello" - } - } - ] - } - } - }, - "spans": { - "0": { - "_metrics_summary": { - "invalid": { - "": { - "err": [ - [ - "invalid_data", - { - "reason": "failed to parse metric" - } - ] - ], - "val": [ - { - "count": 2, - "max": 20.0, - "min": 1.0, - "sum": 21.0, - "tags": { - "transaction": "/hello" - } - } - ] - } - } - } - } - } - } - } - "###); - } - #[test] fn test_skip_span_normalization_when_configured() { let json = r#"{ diff --git a/relay-event-normalization/src/normalize/mod.rs b/relay-event-normalization/src/normalize/mod.rs index 6d8e3d72865..9db1472cc0b 100644 --- a/relay-event-normalization/src/normalize/mod.rs +++ b/relay-event-normalization/src/normalize/mod.rs @@ -1718,7 +1718,6 @@ mod tests { sentry_tags: ~, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -1763,7 +1762,6 @@ mod tests { sentry_tags: ~, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -1808,7 +1806,6 @@ mod tests { sentry_tags: ~, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, diff --git a/relay-event-schema/src/protocol/event.rs b/relay-event-schema/src/protocol/event.rs index d50f4785e38..df5e7bcf11c 100644 --- a/relay-event-schema/src/protocol/event.rs +++ b/relay-event-schema/src/protocol/event.rs @@ -12,10 +12,9 @@ use crate::processor::ProcessValue; use crate::protocol::{ AppContext, Breadcrumb, Breakdowns, BrowserContext, ClientSdkInfo, Contexts, Csp, DebugMeta, DefaultContext, DeviceContext, EventType, Exception, ExpectCt, ExpectStaple, Fingerprint, - GpuContext, Hpkp, LenientString, Level, LogEntry, Measurements, Metrics, MetricsSummary, - MonitorContext, OsContext, ProfileContext, RelayInfo, Request, ResponseContext, RuntimeContext, - Span, SpanId, Stacktrace, Tags, TemplateInfo, Thread, Timestamp, TraceContext, TransactionInfo, - User, Values, + GpuContext, Hpkp, LenientString, Level, LogEntry, Measurements, Metrics, MonitorContext, + OsContext, ProfileContext, RelayInfo, Request, ResponseContext, RuntimeContext, Span, SpanId, + Stacktrace, Tags, TemplateInfo, Thread, Timestamp, TraceContext, TransactionInfo, User, Values, }; /// Wrapper around a UUID with slightly different formatting. @@ -483,13 +482,6 @@ pub struct Event { #[metastructure(omit_from_schema)] pub _metrics: Annotated, - /// Temporary protocol support for metric summaries. - /// - /// This shall move to a stable location once we have stabilized the - /// interface. This is intentionally not typed today. - #[metastructure(omit_from_schema)] - pub _metrics_summary: Annotated, - /// Value of the `DynamicSamplingContext` for this event. #[metastructure(omit_from_schema)] pub _dsc: Annotated, diff --git a/relay-event-schema/src/protocol/span.rs b/relay-event-schema/src/protocol/span.rs index 2c7d1dcb4d1..140f53300de 100644 --- a/relay-event-schema/src/protocol/span.rs +++ b/relay-event-schema/src/protocol/span.rs @@ -6,8 +6,8 @@ use relay_protocol::{ use crate::processor::ProcessValue; use crate::protocol::{ - EventId, IpAddr, JsonLenientString, LenientString, Measurements, MetricsSummary, OperationType, - OriginType, SpanId, SpanStatus, ThreadId, Timestamp, TraceId, + EventId, IpAddr, JsonLenientString, LenientString, Measurements, OperationType, OriginType, + SpanId, SpanStatus, ThreadId, Timestamp, TraceId, }; #[derive(Clone, Debug, Default, PartialEq, Empty, FromValue, IntoValue, ProcessValue)] @@ -93,13 +93,6 @@ pub struct Span { #[metastructure(omit_from_schema)] // we only document error events for now pub measurements: Annotated, - /// Temporary protocol support for metric summaries. - /// - /// This shall move to a stable location once we have stabilized the - /// interface. This is intentionally not typed today. - #[metastructure(skip_serialization = "empty", trim = "false")] - pub _metrics_summary: Annotated, - /// Platform identifier. /// /// See [`Event::platform`](`crate::protocol::Event::platform`). diff --git a/relay-event-schema/src/protocol/span/convert.rs b/relay-event-schema/src/protocol/span/convert.rs index 40ffe1f90c1..0c6c0f06392 100644 --- a/relay-event-schema/src/protocol/span/convert.rs +++ b/relay-event-schema/src/protocol/span/convert.rs @@ -17,7 +17,6 @@ impl From<&Event> for Span { measurements, _metrics, - _metrics_summary, .. } = event; @@ -63,7 +62,6 @@ impl From<&Event> for Span { sentry_tags: Default::default(), received: received.clone(), measurements: measurements.clone(), - _metrics_summary: _metrics_summary.clone(), platform: platform.clone(), was_transaction: true.into(), other: Default::default(), @@ -104,19 +102,6 @@ mod tests { } } }, - "_metrics_summary": { - "some_metric": [ - { - "min": 1.0, - "max": 2.0, - "sum": 3.0, - "count": 2, - "tags": { - "environment": "test" - } - } - ] - }, "measurements": { "memory": { "value": 9001.0, @@ -242,21 +227,6 @@ mod tests { }, }, ), - _metrics_summary: MetricsSummary( - { - "some_metric": [ - MetricSummary { - min: 1.0, - max: 2.0, - sum: 3.0, - count: 2, - tags: { - "environment": "test", - }, - }, - ], - }, - ), platform: "php", was_transaction: true, other: {}, diff --git a/relay-pii/src/snapshots/relay_pii__processor__tests__does_not_scrub_if_no_graphql.snap b/relay-pii/src/snapshots/relay_pii__processor__tests__does_not_scrub_if_no_graphql.snap index 11bb23c4f8b..1dbb4a7b3c1 100644 --- a/relay-pii/src/snapshots/relay_pii__processor__tests__does_not_scrub_if_no_graphql.snap +++ b/relay-pii/src/snapshots/relay_pii__processor__tests__does_not_scrub_if_no_graphql.snap @@ -108,7 +108,6 @@ Event { breakdowns: ~, scraping_attempts: ~, _metrics: ~, - _metrics_summary: ~, _dsc: ~, other: {}, } diff --git a/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_with_variables.snap b/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_with_variables.snap index de44fc55803..78701799480 100644 --- a/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_with_variables.snap +++ b/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_with_variables.snap @@ -108,7 +108,6 @@ Event { breakdowns: ~, scraping_attempts: ~, _metrics: ~, - _metrics_summary: ~, _dsc: ~, other: {}, } diff --git a/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_without_variables.snap b/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_without_variables.snap index daee6f056bb..2dbe3b6ec4a 100644 --- a/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_without_variables.snap +++ b/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_graphql_response_data_without_variables.snap @@ -89,7 +89,6 @@ Event { breakdowns: ~, scraping_attempts: ~, _metrics: ~, - _metrics_summary: ~, _dsc: ~, other: {}, } diff --git a/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_original_value.snap b/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_original_value.snap index 680f80e8834..4d22e576c6f 100644 --- a/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_original_value.snap +++ b/relay-pii/src/snapshots/relay_pii__processor__tests__scrub_original_value.snap @@ -121,7 +121,6 @@ Event { breakdowns: ~, scraping_attempts: ~, _metrics: ~, - _metrics_summary: ~, _dsc: ~, other: {}, } diff --git a/relay-pii/src/snapshots/relay_pii__processor__tests__sentry_user.snap b/relay-pii/src/snapshots/relay_pii__processor__tests__sentry_user.snap index f30b6409b2f..dbd99f4ef4a 100644 --- a/relay-pii/src/snapshots/relay_pii__processor__tests__sentry_user.snap +++ b/relay-pii/src/snapshots/relay_pii__processor__tests__sentry_user.snap @@ -106,7 +106,6 @@ Event { breakdowns: ~, scraping_attempts: ~, _metrics: ~, - _metrics_summary: ~, _dsc: ~, other: {}, } diff --git a/relay-server/src/metrics_extraction/event.rs b/relay-server/src/metrics_extraction/event.rs index 9bb8de85190..1cd67f409d7 100644 --- a/relay-server/src/metrics_extraction/event.rs +++ b/relay-server/src/metrics_extraction/event.rs @@ -9,8 +9,8 @@ use relay_quotas::DataCategory; use relay_sampling::evaluation::SamplingDecision; use crate::metrics_extraction::generic::{self, Extractable}; +use crate::metrics_extraction::transactions; use crate::metrics_extraction::transactions::ExtractedMetrics; -use crate::metrics_extraction::{metrics_summary, transactions}; use crate::services::processor::extract_transaction_span; use crate::statsd::RelayTimers; @@ -89,9 +89,7 @@ fn extract_span_metrics_for_event( let mut span_count = 0; if let Some(transaction_span) = extract_transaction_span(event, max_tag_value_size, &[]) { - let (metrics, metrics_summary) = - metrics_summary::extract_and_summarize_metrics(&transaction_span, config); - metrics_summary.apply_on(&mut event._metrics_summary); + let metrics = generic::extract_metrics(&transaction_span, config); output.project_metrics.extend(metrics); span_count += 1; } @@ -99,9 +97,7 @@ fn extract_span_metrics_for_event( if let Some(spans) = event.spans.value_mut() { for annotated_span in spans { if let Some(span) = annotated_span.value_mut() { - let (metrics, metrics_summary) = - metrics_summary::extract_and_summarize_metrics(span, config); - metrics_summary.apply_on(&mut span._metrics_summary); + let metrics = generic::extract_metrics(span, config); output.project_metrics.extend(metrics); span_count += 1; } @@ -175,7 +171,7 @@ mod tests { use insta::assert_debug_snapshot; use relay_dynamic_config::{ ErrorBoundary, Feature, FeatureSet, GlobalConfig, MetricExtractionConfig, - MetricExtractionGroups, MetricSpec, ProjectConfig, + MetricExtractionGroups, ProjectConfig, }; use relay_event_normalization::{normalize_event, NormalizationConfig}; use relay_event_schema::protocol::Timestamp; @@ -1879,135 +1875,4 @@ mod tests { assert_eq!(&*metrics[3].name, "d:spans/duration@millisecond"); assert_eq!(&*metrics[4].name, "d:spans/duration_light@millisecond"); } - - #[test] - fn test_metrics_summaries_on_transaction_and_spans() { - let mut event = Annotated::from_json( - r#" - { - "type": "transaction", - "sdk": {"name": "sentry.javascript.react-native"}, - "start_timestamp": "2021-04-26T07:59:01+0100", - "timestamp": "2021-04-26T08:00:00+0100", - "release": "1.2.3", - "transaction": "gEt /api/:version/users/", - "transaction_info": {"source": "custom"}, - "platform": "cocoa", - "contexts": { - "trace": { - "trace_id": "ff62a8b040f340bda5d830223def1d81", - "span_id": "bd429c44b67a3eb4", - "op": "ui.load" - }, - "device": { - "family": "iOS", - "model": "iPhone1,1" - }, - "app": { - "app_identifier": "org.reactjs.native.example.RnDiffApp", - "app_name": "RnDiffApp" - }, - "os": { - "name": "iOS", - "version": "16.2" - } - }, - "measurements": { - "app_start_warm": { - "value": 1.0, - "unit": "millisecond" - } - }, - "spans": [ - { - "op": "ui.load.initial_display", - "span_id": "bd429c44b67a3eb2", - "start_timestamp": 1597976300.0000000, - "timestamp": 1597976303.0000000, - "trace_id": "ff62a8b040f340bda5d830223def1d81", - "data": { - "frames.slow": 1, - "frames.frozen": 2, - "frames.total": 9, - "frames.delay": 0.1 - }, - "_metrics_summary": { - "d:spans/duration@millisecond": [ - { - "min": 50.0, - "max": 60.0, - "sum": 100.0, - "count": 2, - "tags": { - "app_start_type": "warm", - "device.class": "1" - } - } - ] - } - } - ], - "_metrics_summary": { - "d:spans/duration@millisecond": [ - { - "min": 50.0, - "max": 100.0, - "sum": 150.0, - "count": 2, - "tags": { - "app_start_type": "warm", - "device.class": "1" - } - } - ] - } - } - "#, - ) - .unwrap(); - - // Normalize first, to make sure that all things are correct as in the real pipeline: - normalize_event( - &mut event, - &NormalizationConfig { - enrich_spans: true, - device_class_synthesis_config: true, - ..Default::default() - }, - ); - - let metric_extraction = MetricExtractionConfig { - version: 4, - metrics: vec![MetricSpec { - category: DataCategory::Span, - mri: "d:custom/my_metric@millisecond".to_owned(), - field: Some("span.duration".to_owned()), - condition: None, - tags: vec![], - }], - ..MetricExtractionConfig::default() - }; - let binding = combined_config( - [Feature::ExtractCommonSpanMetricsFromEvent], - Some(metric_extraction), - ); - let config = binding.combined(); - - let _ = extract_metrics( - event.value_mut().as_mut().unwrap(), - config, - SamplingDecision::Keep, - ProjectId::new(4711), - 200, - true, - ); - - insta::assert_debug_snapshot!(&event.value().unwrap()._metrics_summary); - insta::assert_debug_snapshot!( - &event.value().unwrap().spans.value().unwrap()[0] - .value() - .unwrap() - ._metrics_summary - ); - } } diff --git a/relay-server/src/metrics_extraction/metrics_summary.rs b/relay-server/src/metrics_extraction/metrics_summary.rs deleted file mode 100644 index e784a78e344..00000000000 --- a/relay-server/src/metrics_extraction/metrics_summary.rs +++ /dev/null @@ -1,715 +0,0 @@ -use crate::metrics_extraction::generic; -use crate::metrics_extraction::generic::Extractable; -use relay_base_schema::metrics::{MetricName, MetricNamespace}; -use relay_dynamic_config::CombinedMetricExtractionConfig; -use relay_event_schema::protocol as event; -use relay_metrics::{ - Bucket, BucketValue, CounterType, DistributionValue, FiniteF64, GaugeValue, SetValue, -}; -use relay_protocol::Annotated; -use std::collections::BTreeMap; -use std::ops::AddAssign; - -/// Maps two [`Option`] values using a provided function. -fn map_multiple(a: Option, b: Option, f: fn(T, T) -> T) -> Option { - match (a, b) { - (Some(x), Some(y)) => Some(f(x, y)), - (Some(x), None) => Some(x), - (None, Some(y)) => Some(y), - (None, None) => None, - } -} - -/// Key of a bucket used to keep track of aggregates for the [`MetricsSummary`]. -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -struct MetricsSummaryBucketKey { - /// Name of the metric. - metric_name: MetricName, - /// Tags of the bucket. - tags: BTreeMap, -} - -/// Value of a bucket used to keep track of aggregates for the [`MetricsSummary`]. -#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)] -struct MetricsSummaryBucketValue { - /// The minimum value reported in the bucket. - min: Option, - /// The maximum value reported in the bucket. - max: Option, - /// The sum of all values reported in the bucket. - sum: Option, - /// The number of times this bucket was updated with a new value. - count: u64, -} - -impl AddAssign for MetricsSummaryBucketValue { - fn add_assign(&mut self, rhs: Self) { - *self = MetricsSummaryBucketValue { - min: map_multiple(self.min, rhs.min, std::cmp::min), - max: map_multiple(self.max, rhs.max, std::cmp::max), - sum: map_multiple(self.sum, rhs.sum, |l, r| l.saturating_add(r)), - count: self.count + rhs.count, - } - } -} - -impl<'a> From<&'a BucketValue> for MetricsSummaryBucketValue { - fn from(value: &'a BucketValue) -> Self { - match value { - BucketValue::Counter(counter) => counter.into(), - BucketValue::Distribution(distribution) => distribution.into(), - BucketValue::Set(set) => set.into(), - BucketValue::Gauge(gauge) => gauge.into(), - } - } -} - -impl<'a> From<&'a CounterType> for MetricsSummaryBucketValue { - fn from(counter: &'a CounterType) -> Self { - MetricsSummaryBucketValue { - min: Some(*counter), - max: Some(*counter), - sum: Some(*counter), - count: 1, - } - } -} - -impl<'a> From<&'a DistributionValue> for MetricsSummaryBucketValue { - fn from(distribution: &'a DistributionValue) -> Self { - let mut min = FiniteF64::MAX; - let mut max = FiniteF64::MIN; - let mut sum = FiniteF64::new(0.0).unwrap(); - - for value in distribution { - min = std::cmp::min(min, *value); - max = std::cmp::max(max, *value); - sum = sum.saturating_add(*value); - } - - MetricsSummaryBucketValue { - min: Some(min), - max: Some(max), - sum: Some(sum), - count: distribution.len() as u64, - } - } -} - -impl<'a> From<&'a SetValue> for MetricsSummaryBucketValue { - fn from(set: &'a SetValue) -> Self { - // For sets, we limit to counting the number of occurrences. - MetricsSummaryBucketValue { - min: None, - max: None, - sum: None, - count: set.len() as u64, - } - } -} - -impl<'a> From<&'a GaugeValue> for MetricsSummaryBucketValue { - fn from(gauge: &'a GaugeValue) -> Self { - MetricsSummaryBucketValue { - min: Some(gauge.min), - max: Some(gauge.max), - sum: Some(gauge.sum), - count: gauge.count, - } - } -} - -/// [`MetricsSummary`] that tracks all the buckets containing the summaries for each -/// [`MetricsSummaryBucketKey`]. -/// -/// The need for a [`MetricsSummary`] arises from the fact that we want to compute metrics summaries -/// generically on any slice of [`Bucket`]s meaning that we need to handle cases in which -/// the same metrics as identified by the [`MetricsSummaryBucketKey`] have to be merged. -/// -/// The [`MetricsSummary`] is a different in-memory representation of a metric summary from the -/// [`event::MetricsSummary`]. -#[derive(Debug, Default)] -pub struct MetricsSummary { - buckets: BTreeMap, -} - -impl MetricsSummary { - fn new() -> MetricsSummary { - MetricsSummary { - buckets: BTreeMap::new(), - } - } - - /// Merges into the [`MetricsSummary`] a slice of [`Bucket`]s. - fn from_buckets<'a>(buckets: impl Iterator) -> MetricsSummary { - let mut metrics_summary_spec = MetricsSummary::new(); - - for bucket in buckets { - metrics_summary_spec.merge_bucket(bucket); - } - - metrics_summary_spec - } - - /// Merges a [`Bucket`] into the [`MetricsSummary`]. - fn merge_bucket(&mut self, bucket: &Bucket) { - let key = MetricsSummaryBucketKey { - metric_name: bucket.name.clone(), - tags: bucket.tags.clone(), - }; - - let value = (&bucket.value).into(); - self.buckets - .entry(key) - .and_modify(|e| *e += value) - .or_insert(value); - } - - /// Applies the [`MetricsSummary`] on a receiving [`Annotated`]. - pub fn apply_on(self, receiver: &mut Annotated) { - if self.buckets.is_empty() { - return; - } - - let event::MetricsSummary(metrics_summary_mapping) = - &mut receiver.get_or_insert_with(|| event::MetricsSummary(BTreeMap::new())); - - for (key, value) in self.buckets { - let metric_summary = event::MetricSummary { - min: value.min.map(|m| m.to_f64()).into(), - max: value.max.map(|m| m.to_f64()).into(), - sum: value.sum.map(|m| m.to_f64()).into(), - count: Annotated::new(value.count), - tags: Annotated::new( - key.tags - .into_iter() - .map(|(tag_key, tag_value)| (tag_key, Annotated::new(tag_value))) - .collect(), - ), - }; - - let existing_summary = metrics_summary_mapping - .get_mut(key.metric_name.as_ref()) - .and_then(|v| v.value_mut().as_mut()); - - if let Some(summaries) = existing_summary { - let found = summaries.iter_mut().find_map(|s| { - s.value_mut() - .as_mut() - .filter(|v| v.tags == metric_summary.tags) - }); - - if let Some(found) = found { - found.merge(metric_summary); - } else { - summaries.push(Annotated::new(metric_summary)); - } - } else { - metrics_summary_mapping.insert( - key.metric_name.to_string(), - Annotated::new(vec![Annotated::new(metric_summary)]), - ); - } - } - } -} - -/// Computes the [`MetricsSummary`] from a slice of [`Bucket`]s that belong to -/// [`MetricNamespace::Custom`]. -fn compute(buckets: &[Bucket]) -> MetricsSummary { - // For now, we only want metrics summaries to be extracted for custom metrics. - let filtered_buckets = buckets - .iter() - .filter(|b| matches!(b.name.namespace(), MetricNamespace::Custom)); - - MetricsSummary::from_buckets(filtered_buckets) -} - -/// Extract metrics and summarizes them. -pub fn extract_and_summarize_metrics( - instance: &T, - config: CombinedMetricExtractionConfig<'_>, -) -> (Vec, MetricsSummary) -where - T: Extractable, -{ - let metrics = generic::extract_metrics(instance, config); - let metrics_summaries = compute(&metrics); - - (metrics, metrics_summaries) -} - -#[cfg(test)] -mod tests { - use crate::metrics_extraction::metrics_summary::{MetricsSummary, MetricsSummaryBucketValue}; - use relay_common::time::UnixTimestamp; - use relay_event_schema::protocol as event; - use relay_metrics::{Bucket, FiniteF64}; - use relay_protocol::Annotated; - use std::collections::BTreeMap; - - fn build_buckets(slice: &[u8]) -> Vec { - Bucket::parse_all(slice, UnixTimestamp::now()) - .map(|b| b.unwrap()) - .collect() - } - - #[test] - fn test_with_counter_buckets() { - let buckets = - build_buckets(b"my_counter:3|c|#platform:ios\nmy_counter:2|c|#platform:android"); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(BTreeMap::new())); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 2.0, - max: 2.0, - sum: 2.0, - count: 1, - tags: { - "platform": "android", - }, - }, - MetricSummary { - min: 3.0, - max: 3.0, - sum: 3.0, - count: 1, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_with_distribution_buckets() { - let buckets = - build_buckets(b"my_dist:3.0:5.0|d|#platform:ios\nmy_dist:2.0:4.0|d|#platform:android"); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(BTreeMap::new())); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "d:custom/my_dist@none": [ - MetricSummary { - min: 2.0, - max: 4.0, - sum: 6.0, - count: 2, - tags: { - "platform": "android", - }, - }, - MetricSummary { - min: 3.0, - max: 5.0, - sum: 8.0, - count: 2, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_with_set_buckets() { - let buckets = - build_buckets(b"my_set:3.0:5.0|s|#platform:ios\nmy_set:2.0:4.0|s|#platform:android"); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(BTreeMap::new())); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "s:custom/my_set@none": [ - MetricSummary { - min: ~, - max: ~, - sum: ~, - count: 2, - tags: { - "platform": "android", - }, - }, - MetricSummary { - min: ~, - max: ~, - sum: ~, - count: 2, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_with_gauge_buckets() { - let buckets = - build_buckets(b"my_gauge:3.0|g|#platform:ios\nmy_gauge:2.0|g|#platform:android"); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(BTreeMap::new())); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "g:custom/my_gauge@none": [ - MetricSummary { - min: 2.0, - max: 2.0, - sum: 2.0, - count: 1, - tags: { - "platform": "android", - }, - }, - MetricSummary { - min: 3.0, - max: 3.0, - sum: 3.0, - count: 1, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_merge_buckets() { - let mut buckets = - build_buckets(b"my_counter:3|c|#platform:ios\nmy_counter:2|c|#platform:ios"); - buckets.extend(build_buckets( - b"my_dist:3.0:5.0|d|#platform:ios\nmy_dist:2.0:4.0|d|#platform:ios", - )); - buckets.extend(build_buckets( - b"my_set:3.0:5.0|s|#platform:ios\nmy_set:2.0:4.0|s|#platform:ios", - )); - buckets.extend(build_buckets( - b"my_gauge:3.0|g|#platform:ios\nmy_gauge:2.0|g|#platform:ios", - )); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(BTreeMap::new())); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 2.0, - max: 3.0, - sum: 5.0, - count: 2, - tags: { - "platform": "ios", - }, - }, - ], - "d:custom/my_dist@none": [ - MetricSummary { - min: 2.0, - max: 5.0, - sum: 14.0, - count: 4, - tags: { - "platform": "ios", - }, - }, - ], - "g:custom/my_gauge@none": [ - MetricSummary { - min: 2.0, - max: 3.0, - sum: 5.0, - count: 2, - tags: { - "platform": "ios", - }, - }, - ], - "s:custom/my_set@none": [ - MetricSummary { - min: ~, - max: ~, - sum: ~, - count: 4, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_apply_on_with_different_metric() { - let buckets = build_buckets(b"my_counter:3|c|#platform:ios"); - let mut tags_map = BTreeMap::new(); - tags_map.insert("region".to_owned(), Annotated::new("us".to_owned())); - let mut summary_map = BTreeMap::new(); - summary_map.insert( - "c:custom/my_other_counter@none".to_owned(), - Annotated::new(vec![Annotated::new(event::MetricSummary { - min: Annotated::new(5.0), - max: Annotated::new(10.0), - sum: Annotated::new(15.0), - count: Annotated::new(2), - tags: Annotated::new(tags_map), - })]), - ); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(summary_map)); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 3.0, - max: 3.0, - sum: 3.0, - count: 1, - tags: { - "platform": "ios", - }, - }, - ], - "c:custom/my_other_counter@none": [ - MetricSummary { - min: 5.0, - max: 10.0, - sum: 15.0, - count: 2, - tags: { - "region": "us", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_apply_on_with_same_metric_and_different_tags() { - let buckets = build_buckets(b"my_counter:3|c|#platform:ios"); - let mut tags_map = BTreeMap::new(); - tags_map.insert("region".to_owned(), Annotated::new("us".to_owned())); - let mut summary_map = BTreeMap::new(); - summary_map.insert( - "c:custom/my_counter@none".to_owned(), - Annotated::new(vec![Annotated::new(event::MetricSummary { - min: Annotated::new(5.0), - max: Annotated::new(10.0), - sum: Annotated::new(15.0), - count: Annotated::new(2), - tags: Annotated::new(tags_map), - })]), - ); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(summary_map)); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 5.0, - max: 10.0, - sum: 15.0, - count: 2, - tags: { - "region": "us", - }, - }, - MetricSummary { - min: 3.0, - max: 3.0, - sum: 3.0, - count: 1, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_apply_on_with_same_metric_and_same_tags() { - let buckets = build_buckets(b"my_counter:3|c|#platform:ios"); - let mut tags_map = BTreeMap::new(); - tags_map.insert("platform".to_owned(), Annotated::new("ios".to_owned())); - let mut summary_map = BTreeMap::new(); - summary_map.insert( - "c:custom/my_counter@none".to_owned(), - Annotated::new(vec![Annotated::new(event::MetricSummary { - min: Annotated::new(5.0), - max: Annotated::new(10.0), - sum: Annotated::new(15.0), - count: Annotated::new(2), - tags: Annotated::new(tags_map), - })]), - ); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(summary_map)); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 3.0, - max: 10.0, - sum: 18.0, - count: 3, - tags: { - "platform": "ios", - }, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_apply_on_with_same_metric_and_same_empty_tags() { - let buckets = build_buckets(b"my_counter:3|c"); - let mut summary_map = BTreeMap::new(); - summary_map.insert( - "c:custom/my_counter@none".to_owned(), - Annotated::new(vec![Annotated::new(event::MetricSummary { - min: Annotated::new(5.0), - max: Annotated::new(10.0), - sum: Annotated::new(15.0), - count: Annotated::new(2), - tags: Annotated::new(BTreeMap::new()), - })]), - ); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(summary_map)); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 3.0, - max: 10.0, - sum: 18.0, - count: 3, - tags: {}, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_apply_on_with_same_metric_and_same_empty_tags_and_none_values() { - let buckets = build_buckets(b"my_counter:3|c"); - let mut summary_map = BTreeMap::new(); - summary_map.insert( - "c:custom/my_counter@none".to_owned(), - Annotated::new(vec![Annotated::new(event::MetricSummary { - min: Annotated::empty(), - max: Annotated::new(10.0), - sum: Annotated::empty(), - count: Annotated::new(2), - tags: Annotated::new(BTreeMap::new()), - })]), - ); - - let metrics_summary_spec = MetricsSummary::from_buckets(buckets.iter()); - let mut metrics_summary = Annotated::new(event::MetricsSummary(summary_map)); - metrics_summary_spec.apply_on(&mut metrics_summary); - - insta::assert_debug_snapshot!(metrics_summary.value().unwrap(), @r###" - MetricsSummary( - { - "c:custom/my_counter@none": [ - MetricSummary { - min: 3.0, - max: 10.0, - sum: 3.0, - count: 3, - tags: {}, - }, - ], - }, - ) - "###); - } - - #[test] - fn test_bucket_value_merge() { - let mut value_1 = MetricsSummaryBucketValue { - min: Some(FiniteF64::MIN), - max: None, - sum: None, - count: 0, - }; - - let value_2 = MetricsSummaryBucketValue { - min: None, - max: Some(FiniteF64::MAX), - sum: Some(FiniteF64::from(10)), - count: 10, - }; - - value_1 += value_2; - - assert_eq!( - value_1, - MetricsSummaryBucketValue { - min: Some(FiniteF64::MIN), - max: Some(FiniteF64::MAX), - sum: Some(FiniteF64::from(10)), - count: 10 - } - ); - } -} diff --git a/relay-server/src/metrics_extraction/mod.rs b/relay-server/src/metrics_extraction/mod.rs index 7ba6cd6db8e..4980fe01071 100644 --- a/relay-server/src/metrics_extraction/mod.rs +++ b/relay-server/src/metrics_extraction/mod.rs @@ -3,7 +3,6 @@ use relay_metrics::Bucket; pub mod event; pub mod generic; -pub mod metrics_summary; pub mod sessions; pub mod transactions; diff --git a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap b/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap index 8e513e600e4..f471f6df99b 100644 --- a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap +++ b/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__extract_span_metrics_mobile.snap @@ -51,7 +51,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -198,7 +197,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, }, ), - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -252,7 +250,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -303,7 +300,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -356,7 +352,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -409,7 +404,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -531,7 +525,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -651,7 +644,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -705,7 +697,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -827,7 +818,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, @@ -949,7 +939,6 @@ expression: "(&event.value().unwrap().spans, metrics.project_metrics)" }, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, diff --git a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__metrics_summaries_on_transaction_and_spans-2.snap b/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__metrics_summaries_on_transaction_and_spans-2.snap deleted file mode 100644 index 4b5768c9379..00000000000 --- a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__metrics_summaries_on_transaction_and_spans-2.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: relay-server/src/metrics_extraction/event.rs -expression: "&event.value().unwrap().spans.value().unwrap()[0].value().unwrap()._metrics_summary" ---- -MetricsSummary( - { - "d:custom/my_metric@millisecond": [ - MetricSummary { - min: 3000.0, - max: 3000.0, - sum: 3000.0, - count: 1, - tags: {}, - }, - ], - "d:spans/duration@millisecond": [ - MetricSummary { - min: 50.0, - max: 60.0, - sum: 100.0, - count: 2, - tags: { - "app_start_type": "warm", - "device.class": "1", - }, - }, - ], - }, -) diff --git a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__metrics_summaries_on_transaction_and_spans.snap b/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__metrics_summaries_on_transaction_and_spans.snap deleted file mode 100644 index 56f4f7b5c74..00000000000 --- a/relay-server/src/metrics_extraction/snapshots/relay_server__metrics_extraction__event__tests__metrics_summaries_on_transaction_and_spans.snap +++ /dev/null @@ -1,29 +0,0 @@ ---- -source: relay-server/src/metrics_extraction/event.rs -expression: "&event.value().unwrap()._metrics_summary" ---- -MetricsSummary( - { - "d:custom/my_metric@millisecond": [ - MetricSummary { - min: 59000.0, - max: 59000.0, - sum: 59000.0, - count: 1, - tags: {}, - }, - ], - "d:spans/duration@millisecond": [ - MetricSummary { - min: 50.0, - max: 100.0, - sum: 150.0, - count: 2, - tags: { - "app_start_type": "warm", - "device.class": "1", - }, - }, - ], - }, -) diff --git a/relay-server/src/metrics_extraction/transactions/mod.rs b/relay-server/src/metrics_extraction/transactions/mod.rs index 9828b5cc384..50c9a20e612 100644 --- a/relay-server/src/metrics_extraction/transactions/mod.rs +++ b/relay-server/src/metrics_extraction/transactions/mod.rs @@ -654,7 +654,6 @@ mod tests { sentry_tags: ~, received: ~, measurements: ~, - _metrics_summary: ~, platform: ~, was_transaction: ~, other: {}, diff --git a/relay-server/src/services/processor/span/processing.rs b/relay-server/src/services/processor/span/processing.rs index 4ce58d0dfb8..ba41e57ce00 100644 --- a/relay-server/src/services/processor/span/processing.rs +++ b/relay-server/src/services/processor/span/processing.rs @@ -29,7 +29,7 @@ use relay_spans::otel_trace::Span as OtelSpan; use thiserror::Error; use crate::envelope::{ContentType, Item, ItemType}; -use crate::metrics_extraction::{event, metrics_summary}; +use crate::metrics_extraction::{event, generic}; use crate::services::outcome::{DiscardReason, Outcome}; use crate::services::processor::span::extract_transaction_span; use crate::services::processor::{ @@ -127,11 +127,10 @@ pub fn process( return ItemAction::Drop(Outcome::Invalid(DiscardReason::Internal)); }; - let (metrics, metrics_summary) = metrics_summary::extract_and_summarize_metrics( + let metrics = generic::extract_metrics( span, CombinedMetricExtractionConfig::new(global_metrics_config, config), ); - metrics_summary.apply_on(&mut span._metrics_summary); state .extracted_metrics diff --git a/relay-spans/src/span.rs b/relay-spans/src/span.rs index db0375226e1..8352a7caef9 100644 --- a/relay-spans/src/span.rs +++ b/relay-spans/src/span.rs @@ -266,7 +266,6 @@ pub fn otel_to_sentry_span(otel_span: OtelSpan) -> EventSpan { timestamp: Timestamp(end_timestamp).into(), trace_id: TraceId(trace_id).into(), platform: platform.into(), - _metrics_summary: metrics_summary.into(), ..Default::default() } } @@ -696,21 +695,6 @@ mod tests { sentry_tags: ~, received: ~, measurements: ~, - _metrics_summary: MetricsSummary( - { - "some_metric": [ - MetricSummary { - min: 1.0, - max: 2.0, - sum: 3.0, - count: 2, - tags: { - "environment": "test", - }, - }, - ], - }, - ), platform: "php", was_transaction: ~, other: {},