open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Metrics Annotations
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 214
Description
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.
@Timed
@Counted
public void processPayment() {
// business code here
}
The OpenTelemetry Java auto instrumentation supports the @WithSpan annotation for tracing, but has nothing equivalent for metrics yet.
Brainstorming of a few ideas:
- For
@Timedthe type of histogram should be configurable, like@Timed(histogramType = EXPONENTIAL). Other histogram types would be explicit buckets and default buckets. - Explicit buckets should be configurable:
@Timed(buckets = { 0.001, 0.002, 0.003, 0.004 }) - For exponential histograms the resolution should be configurable.
- Static attributes should be configurable:
@Counted(attributes = { "key", "value" }) - Dynamic attributes should be configurable similar to OpenTelemetry's
@SpanAttribute. - Dynamic attributes based on the return value and on an exception thrown would be great.
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation files, tests, or entry points are named. Start by reviewing the existing @WithSpan auto-instrumentation and the discussion of @Timed and @Counted requirements. The work is not ready for a newcomer until the annotation API, supported metric options, tracing interaction, and tests defining done are agreed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100