open-telemetry / opentelemetry-java-instrumentation

OpenTelemetry auto-instrumentation and instrumentation libraries for Java
https://opentelemetry.io
Apache License 2.0
1.96k stars 860 forks source link

Convert gc duration metrics to seconds #12244

Closed laurit closed 2 months ago

laurit commented 2 months ago

https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/12084 changed the unit to seconds but forgot to convert the value from millis to seconds

egahlin commented 2 months ago

> DurationUtil.millisToSeconds(ev.getLong(Constants.DURATION))

This looks strange. The raw value of the "duration" field is in ticks and the conversion factor depends on the platform and machine. The reasonable thing is to do ev.getDuration().toMillis() and let JFR do the conversion.

laurit commented 2 months ago

> DurationUtil.millisToSeconds(ev.getLong(Constants.DURATION))

This looks strange. The raw value of the "duration" field is in ticks and the conversion factor depends on the platform and machine. The reasonable thing is to do ev.getDuration().toMillis() and let JFR do the conversion.

@egahlin Thanks for reporting this. I have created https://github.com/open-telemetry/opentelemetry-java-instrumentation/pull/12256 to address this.