open-telemetry / open-telemetry/opentelemetry-java-contrib

SpanMetricsProcessor for agent instrumentation

Open
#1,018 9 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Java
Stars
269
Forks
196
Avg merge
2d 7h
Merged PRs (30d)
38

Description

Is your feature request related to a problem? Please describe.
Opentelmetry java instrumentation is nicely able to handle the application traces using annotations, a nice feature to have would be to record metrics of the spans using the annotations itself. The metrics would be of the way like span metrics processor does to record the R.E.D metrics.

Describe the solution you'd like
We can use the current span annotations to make a histogram.
Histogram itself will give the counter metrics.
We can define two fields in the annotation, one to disable metrics for a particular method and another to add a gauge for the corresponding method.
The whole feature can be disabled by default and can be enabled on demand by using a configuration option.
Attributes of a span can be used as labels and exceptions can be used as the corresponding error metrics (can be thought more on the same).
These metrics can be exposed using the prometheus metrics exporter.

Describe alternatives you've considered
We have currently been using the span metrics processor at the otel collector end for the same purpose where the traces are being pushed and the metrics are consolidated using the processor.

But these metrics are being impacted by the trace sampling set on client. If we make tracing 100% then it can impact performance. Also most of the times the consolidation can easily be handled at the client end easily and further consolidation can take place at prometheus, like most of the applications run today.

Even if we are using a dummy Span (in case of sampled trace), I believe we can record metrics (I may be wrong here), thus allowing us to not push traces 100% of the times yet getting accurate metrics data.

This would further enhance user experience and allow them to record application metrics without much hassel.

Additional Context
A lot of open source tools are adopting span metrics processor for showing R.E.D metrics along side their traces few examples include

Grafana
Signoz
Jaegar

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by reviewing the existing Java span-annotation instrumentation, the span metrics processor approach, and the Prometheus exporter path; clarify where configuration and annotation options belong. Done means an agreed implementation scope covering opt-in metrics, histogram/R.E.D. data, labels, errors, and sampling behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, prometheus
Domain
observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.