-
Notifications
You must be signed in to change notification settings - Fork 917
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
add annotations for metrics #11285
add annotations for metrics #11285
Conversation
@Duncan-tree-zhou do you also plan to provide instrumentation that would use these annotations? |
Yes, I am working on it. But it's a little tricky to setup the test environment. It takes some time.... |
Hi @laurit, I can not run test with JDK 21 after the commit
While I can run the test with JDK 17 in commit Not sure if it's a bug. I see the commit was created by you, do you have any suggestion on how to skip the build failure? |
jdk 21 is now required to build this project, this error happens when you are still using jdk 17 |
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.
Very nice!
* <p>Unit strings should follow the instrument unit rules: <a | ||
* href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument-unit">https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument-unit</a> | ||
*/ | ||
String unit() default "1"; |
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.
String unit() default "1"; | |
String unit() default "{invocation}"; |
See https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation/runtime-telemetry/runtime-telemetry-java8/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/java8/Classes.java#L55 for example of another instrument counting things.
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.
is the "{invocation}" a placeholder? I can not understand how it works from the reference, would you like to amplify a bit more on it?
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.
This explains it in more detail: https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/metrics.md#instrument-units
* <p>Description strings should follow the instrument description rules: <a | ||
* href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument-description">https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#instrument-description</a> | ||
*/ | ||
String description() default "1"; |
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.
Description should probably default to not set.
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.
I aware that the "intrumentation-api-incubator" is not the good place to put the annotations. so I had moved them to "instrumentation-annotations" in another pr #11354. Despite it build failed due to the new instrumentation implementation, I think we can discuss on that one and close this one
* | ||
* <p>Default is millis seconds. | ||
*/ | ||
TimeUnit unit() default TimeUnit.MILLISECONDS; |
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.
The default unit for durations in opentelemetry is seconds. This also means that this needs to record to a DoubleHistogram
instead of a LongHistogram
, which makes no difference because long measurements are converted to doubles anyway before export.
* <li><b>code.namespace:</b> The fully qualified name of the class whose method is invoked. | ||
* <li><b>code.function:</b> The name of the annotated method, or "new" if the annotation is on a |
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 anyone wondering, yes these are consistent with the semantic convention registry. 👍🏻
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.
should I put the link in the code or copy the description from the reference?
...ubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/annotations/Counted.java
Show resolved
Hide resolved
* <p>The name of the attribute for the return value of the method call. {@link Object#toString()} | ||
* will be called on the return value to convert it to a String. | ||
* | ||
* <p>By default, the instrument will not have an attribute with the return value. |
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.
I think that this should also come with a warning that using this can very likely explode metric dimension cardinality.
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.
It's a good point, and MetricAttribute would have the same problem.
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.
I'm stoked on these and can't wait to see them in action!
Hi friends, thanks for your suggestions, I adapt the changes in #11354. |
Initially it's a copy from PR: open-telemetry/opentelemetry-java#4260. I am moving the annotations apis to repo opentelemetry-java-instrumentation , project instrumentation-api-incubator.
orignal issue: #7030