diff --git a/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryCounter.java b/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryCounter.java index 88d3103e2607..18299258fda2 100644 --- a/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryCounter.java +++ b/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryCounter.java @@ -50,7 +50,7 @@ public void increment(double v) { @Override public double count() { UnsupportedReadLogger.logWarning(); - return 0; + return Double.NaN; } @Override diff --git a/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionCounter.java b/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionCounter.java index ba58dcca81fb..55965c424fd6 100644 --- a/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionCounter.java +++ b/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionCounter.java @@ -36,7 +36,7 @@ final class OpenTelemetryFunctionCounter implements FunctionCounter, Removabl @Override public double count() { UnsupportedReadLogger.logWarning(); - return 0; + return Double.NaN; } @Override diff --git a/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionTimer.java b/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionTimer.java index 077ad37cd8a7..a157f057a95e 100644 --- a/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionTimer.java +++ b/instrumentation/micrometer/micrometer-1.5/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/micrometer/v1_5/OpenTelemetryFunctionTimer.java @@ -51,13 +51,17 @@ final class OpenTelemetryFunctionTimer implements FunctionTimer, RemovableMet /* baseUnit = */ "ms", attributes, obj, - new ConvertToMillisDecorator<>(totalTimeFunction, totalTimeFunctionUnit)); + val -> + TimeUtils.convert( + totalTimeFunction.applyAsDouble(val), + totalTimeFunctionUnit, + TimeUnit.MILLISECONDS)); } @Override public double count() { UnsupportedReadLogger.logWarning(); - return 0; + return Double.NaN; } @Override @@ -66,6 +70,12 @@ public double totalTime(TimeUnit unit) { return Double.NaN; } + @Override + public double mean(TimeUnit unit) { + UnsupportedReadLogger.logWarning(); + return Double.NaN; + } + @Override public TimeUnit baseTimeUnit() { return TimeUnit.MILLISECONDS; @@ -98,21 +108,4 @@ public boolean equals(Object o) { public int hashCode() { return MeterEquivalence.hashCode(this); } - - private static final class ConvertToMillisDecorator implements ToDoubleFunction { - - private final ToDoubleFunction original; - private final TimeUnit originalUnit; - - private ConvertToMillisDecorator(ToDoubleFunction original, TimeUnit originalUnit) { - this.original = original; - this.originalUnit = originalUnit; - } - - @Override - public double applyAsDouble(T value) { - double time = original.applyAsDouble(value); - return TimeUtils.convert(time, originalUnit, TimeUnit.MILLISECONDS); - } - } }