Skip to content

Commit c6e52d2

Browse files
authored
Send overflow metric for more cardinality errors (#8740)
1 parent fb18d52 commit c6e52d2

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Fix OTel cardinality overflow metric for more error strings ([PR #8740](https://github.com/apollographql/router/pull/8740))
2+
3+
Emit the apollo.router.telemetry.metrics.cardinality_overflow metric for more instances where an OTel cardinality error has occurred. The message check has been changed to support a different form of the error that has been reported by a customer.
4+
5+
By [@bonnici](https://github.com/bonnici) in https://github.com/apollographql/router/pull/8740

apollo-router/src/plugins/telemetry/error_handler.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ fn handle_error_with_map<T: Into<opentelemetry::global::Error>>(
6161
// Keep track of the number of cardinality overflow errors otel emits. This can be removed after upgrading to 0.28.0 when the cardinality limit is removed.
6262
// The version upgrade will also cause this log to be removed from our visibility even if we were set up custom a cardinality limit.
6363
// https://github.com/open-telemetry/opentelemetry-rust/pull/2528
64-
if err.to_string()
65-
== "Metrics error: Warning: Maximum data points for metric stream exceeded. Entry added to overflow. Subsequent overflows to same metric until next collect will not be logged."
64+
if err
65+
.to_string()
66+
.contains("Maximum data points for metric stream exceeded. Entry added to overflow.")
6667
{
6768
u64_counter!(
6869
"apollo.router.telemetry.metrics.cardinality_overflow",
@@ -326,7 +327,7 @@ mod tests {
326327
}
327328

328329
#[tokio::test]
329-
async fn test_cardinality_overflow() {
330+
async fn test_cardinality_overflow_1() {
330331
async {
331332
let error_map = DashMap::new();
332333
let msg = "Warning: Maximum data points for metric stream exceeded. Entry added to overflow. Subsequent overflows to same metric until next collect will not be logged.";
@@ -344,6 +345,25 @@ mod tests {
344345
.await;
345346
}
346347

348+
#[tokio::test]
349+
async fn test_cardinality_overflow_2() {
350+
async {
351+
let error_map = DashMap::new();
352+
let msg =
353+
"Warning: Maximum data points for metric stream exceeded. Entry added to overflow.";
354+
handle_error_with_map(
355+
opentelemetry::global::Error::Metric(opentelemetry::metrics::MetricsError::Other(
356+
msg.to_string(),
357+
)),
358+
&error_map,
359+
);
360+
361+
assert_counter!("apollo.router.telemetry.metrics.cardinality_overflow", 1);
362+
}
363+
.with_metrics()
364+
.await;
365+
}
366+
347367
// Mock span exporter to test failures
348368
#[derive(Debug)]
349369
struct FailingSpanExporter;

0 commit comments

Comments
 (0)