Skip to content
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

Conversation

Duncan-tree-zhou
Copy link

@Duncan-tree-zhou Duncan-tree-zhou commented May 4, 2024

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

@Duncan-tree-zhou Duncan-tree-zhou requested a review from a team May 4, 2024 10:30
@laurit
Copy link
Contributor

laurit commented May 7, 2024

@Duncan-tree-zhou do you also plan to provide instrumentation that would use these annotations?

@Duncan-tree-zhou
Copy link
Author

Duncan-tree-zhou commented May 7, 2024

@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....

@Duncan-tree-zhou
Copy link
Author

Duncan-tree-zhou commented May 7, 2024

Hi @laurit, I can not run test with JDK 21 after the commit dfc79ebecebe340da2ac911e048150841776046a, it throws failure like:

...
> Task :instrumentation-api-incubator:processResources NO-SOURCE
> Task :custom-checks:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':custom-checks:compileJava'.
> error: invalid flag: -Xlint:-this-escape
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.
...

While I can run the test with JDK 17 in commit c92955fa2fb8beae9cf599bb164dd9d9cbd15805 (the one before upgrade sdk to 21).

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?

@laurit
Copy link
Contributor

laurit commented May 8, 2024

Hi @laurit, I can not run test with JDK 21 after the commit dfc79ebecebe340da2ac911e048150841776046a, it throws failure like:

...
> Task :instrumentation-api-incubator:processResources NO-SOURCE
> Task :custom-checks:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':custom-checks:compileJava'.
> error: invalid flag: -Xlint:-this-escape
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Get more help at https://help.gradle.org.
...

jdk 21 is now required to build this project, this error happens when you are still using jdk 17

Copy link
Member

@jack-berg jack-berg left a 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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* <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";
Copy link
Member

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.

Copy link
Author

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;
Copy link
Member

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.

Comment on lines +20 to +21
* <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
Copy link
Contributor

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. 👍🏻

Copy link
Author

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?

* <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.
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

@breedx-splk breedx-splk left a 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!

@Duncan-tree-zhou
Copy link
Author

Hi friends, thanks for your suggestions, I adapt the changes in #11354.

@trask
Copy link
Member

trask commented May 20, 2024

Hi friends, thanks for your suggestions, I adapt the changes in #11354.

does #11354 replace this PR? if so we can close this one, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants