-
Notifications
You must be signed in to change notification settings - Fork 928
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
Metrics Annotations #7030
Comments
I think things that are a strict SDK responsibility (bucket definitions for example) should not end up being referenced in an annotation, since the annotations should be a pure API artifact. Aside from that detail, I think having something like this would be a great idea. |
Thanks for the quick response. If a user wants to time something that takes microseconds they certainly want to use different buckets than if they time something that takes milliseconds or even seconds. How would a user do that? Are there alternatives to configuring buckets in the annotation? |
At the moment, all configuration of how histograms work (and metrics aggregations in general) is the responsibility of the application operator via SDK configuration, and is not a concern assigned to instrumentation authors. In the future, we may have what we've been calling a "hint" API that would allow instrumentation call sites to inform the SDK of what they would prefer, but that is not currently specified. |
Thanks a lot for the explanation, this makes sense. In that case the annotations would be quite simple, as they only provide configuration options for the metric name and attributes. I could open a PR to add them to |
That would be fine. Since these annotations are generally implemented by the instrumentation folks, I'd love some feedback on this proposal from @trask @mateuszrzeszutek @anuraaga and others. |
I support! please tag @open-telemetry/java-instrumentation-approvers on your PR and we can discuss specifics there |
Opened PR open-telemetry/opentelemetry-java#4260. |
@zeitlinger this could be a good use case for a convenience API until we implement an annotation-driven approach |
While this issue could be implemented with methods, it's quite unrelated (and increasing the scope of) open-telemetry/opentelemetry-java-contrib#759 - but it definitely shows that it's worth evolving the otel apis. |
Hi there, I think it's a very helpful feature for user. Is anyone already working on it? If no, I would like to pick it up. |
I can support @Duncan-tree-zhou on any questions he may have during the contribution process. Thanks Duncan! |
I don't think anyone is working on it right now. |
copy the PR from |
Hi here, I need some help. When I am writing the test cases, I found a bug on the current annotation api design. the problem is caused by the default name. see the following cases: public class CountedExample {
@Counted
public void method1() {
}
@Counted(description = "I am the description.")
public void method2() {
}
@Counted(unit = "kb")
public void method3() {
}
} for method1 it request to create a LongCounter with name "method.invocation.count", empty description and empty unit. So if I create a metric instance for method1, then I can not create the metric for method2 because they are have got a same metric name but with different properties. If we use the same default name for each method with There are at lease two way to reduce the above cases:
I think the second one would be more friendly to the user. No sure if there are any other better solution. |
it seems like there are two different use cases:
maybe we should just target use case 2 for now? or maybe a separate annotation for use case 1, e.g. |
How about to use |
the other solution is to use |
Frameworks like Spring Boot, MicroProfile, and Dropwizard offer annotations like
@Timed
or@Counted
for creating metrics from method calls.The benefit is that developers can provide metrics for their business logic while still separating business code from metrics tracking.
The OpenTelemetry Java auto instrumentation supports the
@WithSpan
annotation for tracing, but has nothing equivalent for metrics yet.Brainstorming of a few ideas:
@Timed
the type of histogram should be configurable, like@Timed(histogramType = EXPONENTIAL)
. Other histogram types would be explicit buckets and default buckets.@Timed(buckets = { 0.001, 0.002, 0.003, 0.004 })
@Counted(attributes = { "key", "value" })
@SpanAttribute
.Moreover, it would be awesome to integrate this with
@WithSpan
so that develpers can say "I want to time this method AND have a Span". However, it should also be possible to use tracing without metrics, because histograms may introduce a lot of cardinality, and users might just want to create a Span without creating a histogram.What do you think, is it worthwhile to put some more thoughts into this?
The text was updated successfully, but these errors were encountered: