Skip to content

Commit 321261e

Browse files
authored
Merge pull request #28943 from Channyboy/fixMetricConversion
Correct API call with conversion to get the right value
2 parents a078e99 + ec579b2 commit 321261e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

dev/io.openliberty.microprofile.telemetry.2.0.internal/src/io/openliberty/microprofile/telemetry20/internal/http/MPTelemetryHTTPMetricsAdapterImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class MPTelemetryHTTPMetricsAdapterImpl implements HTTPMetricAdapter {
3838

3939
private static final String INSTR_SCOPE = "io.openliberty.microprofile.telemetry20.internal.http";
4040

41+
private static final double NANO_CONVERSION = 0.000000001;
42+
4143
@Override
4244
public void updateHttpMetrics(HttpStatAttributes httpStatAttributes, Duration duration, String appName) {
4345
OpenTelemetry otelInstance = OpenTelemetryAccessor.getOpenTelemetryInfo((appName == null) ? OpenTelemetryConstants.OTEL_RUNTIME_INSTANCE_NAME : appName).getOpenTelemetry();
@@ -69,7 +71,9 @@ public void updateHttpMetrics(HttpStatAttributes httpStatAttributes, Duration du
6971
.setExplicitBucketBoundariesAdvice(List.of(0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 5.0, 7.5, 10.0)).build();
7072

7173
Context ctx = Context.current();
72-
dHistogram.record(duration.toSeconds(), retrieveAttributes(httpStatAttributes), ctx);
74+
75+
double seconds = duration.toNanos() * NANO_CONVERSION;
76+
dHistogram.record(seconds, retrieveAttributes(httpStatAttributes), ctx);
7377

7478
}
7579

0 commit comments

Comments
 (0)