Skip to content

Commit

Permalink
Add time units to OTel integration tests
Browse files Browse the repository at this point in the history
The OTel collector had/have multiple bugs around this:
- The time unit is not converted to `seconds` (Prometheus' default)
- The time unit was not even visible in the name of the time series,
this violated the OTel specification

This means that if you sent 123ms to the OTLP collector,
on Prometheus side this turned into 123s
(the value is the same and not having the unit means `seconds`).
See: open-telemetry/opentelemetry-collector-contrib#18903
It seems units are still not converted but at least the unit is in the
name now (breaking change),
see: open-telemetry/opentelemetry-collector-contrib#20519

Because of this breaking change, our tests are also broken and we need to add the unit to our assertions.

Closes gh-3796
  • Loading branch information
jonatan-ivanov committed May 1, 2023
1 parent e2e603a commit f022dde
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ void collectorShouldExportMetrics() throws Exception {
whenPrometheusScraped().then().body(
containsString("{job=\"test\",service_name=\"test\",telemetry_sdk_language=\"java\",telemetry_sdk_name=\"io.micrometer\""),

matchesPattern("(?s)^.*test_counter\\{.+} 42\\.0\\n.*$"),
matchesPattern("(?s)^.*test_counter_total\\{.+} 42\\.0\\n.*$"),
matchesPattern("(?s)^.*test_gauge\\{.+} 12\\.0\\n.*$"),

matchesPattern("(?s)^.*test_timer_count\\{.+} 1\\n.*$"),
// TODO: this should be 123ms (0.123) not 123s (123)
matchesPattern("(?s)^.*test_timer_milliseconds_count\\{.+} 1\\n.*$"),
// TODO: Earlier this was 123s (123), should have been 123ms (0.123)
// see: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/18903
matchesPattern("(?s)^.*test_timer_sum\\{.+} 123\\.0\\n.*$"),
matchesPattern("(?s)^.*test_timer_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"),
// it seems units are still not converted but at least the unit is in the name now (breaking change)
// see: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/20519
matchesPattern("(?s)^.*test_timer_milliseconds_sum\\{.+} 123\\.0\\n.*$"),
matchesPattern("(?s)^.*test_timer_milliseconds_bucket\\{.+,le=\"\\+Inf\"} 1\\n.*$"),

matchesPattern("(?s)^.*test_distributionsummary_count\\{.+} 1\\n.*$"),
matchesPattern("(?s)^.*test_distributionsummary_sum\\{.+} 24\\.0\\n.*$"),
Expand Down

0 comments on commit f022dde

Please sign in to comment.