diff --git a/packages/opentelemetry-node/test/host-metrics.test.js b/packages/opentelemetry-node/test/host-metrics.test.js index 3d22634a..d88d377a 100644 --- a/packages/opentelemetry-node/test/host-metrics.test.js +++ b/packages/opentelemetry-node/test/host-metrics.test.js @@ -44,10 +44,20 @@ const testFixtures = [ metric.gauge, 'data points are present in system.cpu.utilization metric' ); + const allInRange = metric.gauge?.dataPoints.every( + (dp) => dp.asDouble < 1 + ); t.ok( - metric.gauge?.dataPoints.every((dp) => dp.asDouble < 1), + allInRange, '"system.cpu.utilization" data points have a value between 0-1' ); + if (!allInRange) { + // Note: extra output to debug flaky test (https://github.com/elastic/elastic-otel-node/issues/73). + t.comment( + 'cpuUtilizationMetrics: ' + + JSON.stringify(cpuUtilizationMetrics) + ); + } t.ok( metric.gauge?.dataPoints.filter( (dp) =>