-
Notifications
You must be signed in to change notification settings - Fork 945
JMX metrics unit conversion #13448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JMX metrics unit conversion #13448
Conversation
To discuss - should we silently ignore situation when |
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
We must have an explicit unit, so |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding documentation for sourceUnit
will be required in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/jmx-metrics/javaagent/README.md once we agree on the implementation.
...trics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricRegistrar.java
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
According to mandatory unit - YAML is correctly processed if unit is not provided. In such a case the unit is and empty string. |
You are right, the |
@@ -27,21 +27,28 @@ public enum Type { | |||
// How to report the metric using OpenTelemetry API | |||
private final String metricName; // used as Instrument name | |||
@Nullable private final String description; | |||
@Nullable private final String unit; | |||
@Nullable private final String sourceUnit; | |||
private final String unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] unit is required by semconv, so it should not be nullable
I think there are a few issues with the current approach we've taken so far, I'll try to elaborate a bit on what I think could be problematic with this approach. Currently, we assume that an MBean attribute of type When adding the unit conversion, we take in account that the conversion to seconds always produces a However, in the implementation of the unit converter themselves, for example in In short, I think using a unit conversion should:
But the downside here is that it means for every converter, for example So, I think that we really miss here is the ability to know which numeric type should be used for a given metric. As said here (1) using the type of the attribute is a good default but we should provide an explicit option as well. When unit conversion is involved, we could then reuse this information to know how to perform the conversion appropriately. Doing so could also maybe bring a few other use-cases, but I only have one so far:
|
Added support for default sourceUnit defined on rule level
As discussed today, we currently do not have the ability to have an explicit "numeric type" for the produced metric. This is fine for now as we only need to convert to seconds for the JVM/tomcat metrics, which will always produce a As explained here in documentation choosing numeric types can have an impact with overflows, but this could also be something problematic for the consumers of those metrics if they rely on the numeric type (for example distinct storage for |
Converter registration is now package private.
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
...ary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactory.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
void shouldSupportCustomConverter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[for reviewer] this test is more for future-proofing the design of unit conversion, we don't expect for now to provide the ability to register custom converters.
...src/test/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactoryTest.java
Outdated
Show resolved
Hide resolved
...src/test/java/io/opentelemetry/instrumentation/jmx/engine/unit/UnitConverterFactoryTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: SylvainJuge <[email protected]>
Co-authored-by: Jay DeLuca <[email protected]>
…ntelemetry-java-instrumentation into jmx-metric-unit-conversion
cc @PeterF778 in case you have a chance to review |
Comments added
UnitConverter merged with UnitConverterFactory and made package-private
Related to: #13369
Some of JMX enabled applications publish their metrics with units incompatible with semconv. Most frequently it is publishing elapsed time in milliseconds or nanoseconds, while semconv recommends seconds.
We can support semconv recommendations by implementing metric unit conversion mechanism that can be used with YAML JMX configs.
Solution description:
A new YAML property
sourceUnit
can now be specified to define original unit of mapped bean property value.It should be used together with
unit
, which defines unit of metric value reported to the backend.Example:
This means that
totalProcessingTime
bean property is mapped to processingTime metric and value is converted from milliseconds to seconds.If only
unit
is specified and there is nosourceUnit
then no conversion is performed.If only
sourceUnit
is specified and there is nounit
then metric has no unit and no conversion is performed - it is just silently ignored.Note
This PR will be followed by another one which will solve numeric precision issue mentioned below