open-telemetry / open-telemetry/opentelemetry-java-instrumentation

Metrics time cost not equal with Span duration

Open
#5,905 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.