-
Notifications
You must be signed in to change notification settings - Fork 879
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 metric annotation instrumentation #11354
base: main
Are you sure you want to change the base?
add metric annotation instrumentation #11354
Conversation
There are some CI failures, firstly you can solve them by referring to https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/docs/contributing/running-tests.md#troubleshooting-ci-test-failures |
f1797c8
to
f7dd6b9
Compare
...entation-annotations/src/main/java/io/opentelemetry/instrumentation/annotations/Counted.java
Outdated
Show resolved
Hide resolved
Hi @steverao, I found that there are lots of fails "to connect to localhost/127.0.0.1:4318". So I want to rerun the task, but I can't see the rerun button. Is it disabled for contributors? |
Yes, you can fix the problems firstly and push relevant commits. It will trigger to rerun the CI tasks. |
I mean I guest the failure is caused by the CI run time environment crush..... if it's able to rerun a task, It might save some time.... |
815bbfd
to
95f0f0d
Compare
f9657ec
to
5ab650b
Compare
I turn it ready for reviewing, and get some questions for discuss:
|
5024350
to
54866bf
Compare
54866bf
to
21cbf96
Compare
@open-telemetry/java-instrumentation-approvers could you please review |
...nnotations-incubator/src/main/java/io/opentelemetry/instrumentation/annotations/Counted.java
Outdated
Show resolved
Hide resolved
...-incubator/src/main/java/io/opentelemetry/instrumentation/annotations/incubator/Counted.java
Outdated
Show resolved
Hide resolved
...or/src/main/java/io/opentelemetry/instrumentation/annotations/incubator/MetricAttribute.java
Outdated
Show resolved
Hide resolved
...or/src/main/java/io/opentelemetry/instrumentation/annotations/incubator/MetricAttribute.java
Show resolved
Hide resolved
* <p>Warning: be careful to fill it because it might cause an explosion of the cardinality on | ||
* your metric | ||
*/ | ||
String value() default ""; |
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 wonder if it's worth renaming this to name
(even though it would then require providing name =
), so that it's not confusing that this is the "metric value", and consistent with @StaticMetricAttribute
which uses name
/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 don't really like forcing users to use name = "foo"
Micrometer https://github.com/micrometer-metrics/micrometer/blob/main/micrometer-core/src/main/java/io/micrometer/core/aop/MeterTag.java defines key
and value
and says that both represent the name of the tag and value is an alias for key.
* | ||
* <p>If you are a library developer, then probably you should NOT use this annotation, because it | ||
* is non-functional without the OpenTelemetry auto-instrumentation agent, or some other annotation | ||
* processor. |
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.
Can we doc the attribute type that will be used for the metric attribute?
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 attribute type is chosen based on the same logic as with SpanAttribute
. The logic for choosing the type in https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation-annotations-support/src/main/java/io/opentelemetry/instrumentation/api/annotation/support/AttributeBindingFactory.java is quite complicated but in my opinion still not complete. For example it does not handle byte
and short
and their arrays as numeric types. In the span attribute code there are differences between attribute types used in the default and kotlin coroutine implementation.
*/ | ||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MetricAttribute { |
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 would call this @Attribute
and would use it both for metrics and tracing...
We have the @SpanAttribute
witch can record high cardinality data. However, @Attribute
could have a field stating if we want it or not in the trace...
This would avoid having a ton of annotations in method params.
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 totally agree that the current names are not ideal, but I think they are good enough for the first prototype and give a good base to build upon. To be honest I wasn't really interested in driving this effort I only wanted to help getting this PR into mergeable shape.
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 probably worth to discuss this a bit because if we have to change it in the future, it will be yet another breaking change.
@Target(ElementType.METHOD) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Repeatable(StaticMetricAttributes.class) | ||
public @interface StaticMetricAttribute { |
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.
@ StaticMetricAttribute
is a very long name.
refer to #7030
add metric annotation instrumentation