diff --git a/.changesets/fix_bnjjj_fix_5173.md b/.changesets/fix_bnjjj_fix_5173.md new file mode 100644 index 0000000000..307a37b013 --- /dev/null +++ b/.changesets/fix_bnjjj_fix_5173.md @@ -0,0 +1,7 @@ +### Metrics overflow is logged as a warning rather than error ([Issue #5173](https://github.com/apollographql/router/issues/5173)) + +If a metric has too high a cardinality the following warning will be displayed as a warning instead of an errorl: + +`OpenTelemetry metric error occurred: Metrics error: Warning: Maximum data points for metric stream exceeded/ Entry added to overflow` + +By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/5287 \ No newline at end of file diff --git a/apollo-router/src/plugins/telemetry/mod.rs b/apollo-router/src/plugins/telemetry/mod.rs index 61c92ed4c8..1dd3263757 100644 --- a/apollo-router/src/plugins/telemetry/mod.rs +++ b/apollo-router/src/plugins/telemetry/mod.rs @@ -22,6 +22,7 @@ use http::StatusCode; use multimap::MultiMap; use once_cell::sync::OnceCell; use opentelemetry::global::GlobalTracerProvider; +use opentelemetry::metrics::MetricsError; use opentelemetry::propagation::text_map_propagator::FieldIter; use opentelemetry::propagation::Extractor; use opentelemetry::propagation::Injector; @@ -1799,7 +1800,13 @@ fn handle_error_internal>( ::tracing::error!("OpenTelemetry trace error occurred: {}", err) } opentelemetry::global::Error::Metric(err) => { - ::tracing::error!("OpenTelemetry metric error occurred: {}", err) + if let MetricsError::Other(msg) = &err { + if msg.contains("Warning") { + ::tracing::warn!("OpenTelemetry metric warning occurred: {}", msg); + return; + } + } + ::tracing::error!("OpenTelemetry metric error occurred: {}", err); } opentelemetry::global::Error::Other(err) => { ::tracing::error!("OpenTelemetry error occurred: {}", err)