open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Metrics time cost not equal with Span duration
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 214
Description
Describe the bug
In io.opentelemetry.instrumentation.api.instrumenter.Instrumenter,
There will calculate the startTime and endTime for both span and metrics.
But due to the interface of timeExtractor is only implemented by a few of instrumentation,
so the startTime and endTime in span and metrics are different.
In most cases, the time cost (metrics endTime - metrics startTime) in metrics will be smaller than the correspond span duration (span endTime - span startTime).
This is confusing for end users.
Steps to reproduce
Invoke most cases of call.
What did you expect to see?
The time cost (metrics endTime - metrics startTime) in metrics is equal with the correspond span duration (span endTime - span startTime).
What did you see instead?
In most cases, the time cost (metrics endTime - metrics startTime) in metrics will be smaller than the correspond span duration (span endTime - span startTime).
What version are you using?
v1.11.1
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
Start in io.opentelemetry.instrumentation.api.instrumenter.Instrumenter and compare how startTime and endTime are calculated for spans and metrics. Check the timeExtractor interface and its implementations to understand when the values diverge. Done means metrics duration matches the corresponding span duration in the reported cases, with appropriate tests for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability-sre
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100