Skip to content

Span metrics calls count always 0 with delta aggregation temporality #40139

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

Closed
jsonlsy opened this issue May 20, 2025 · 3 comments · Fixed by #40148
Closed

Span metrics calls count always 0 with delta aggregation temporality #40139

jsonlsy opened this issue May 20, 2025 · 3 comments · Fixed by #40148
Labels
bug Something isn't working connector/spanmetrics

Comments

@jsonlsy
Copy link
Contributor

jsonlsy commented May 20, 2025

Component(s)

connector/spanmetrics

What happened?

Description

Kudos to @san-san for finding this bug.

Looks like this PR introduced a bug when using delta aggregation temporality: #39052

With delta aggregation temporality, resourceMetrics get purged after exporting the metrics here. So, the metrics generated are always newly created ones and have isFirst set to true. This results in the value always getting overwritten here.

Can confirm that this is not an issue in v0.123.0 (i.e. prior to the first value logic)

Steps to Reproduce

  • Run collector with the span metrics connector
  • Send a span to the collector
  • Wait for span metrics to be flushed. The value of the calls metrics is 0 instead of 1.
  • Send another span with the same relevant attributes
  • Wait for span metrics to be flushed. The value of the new calls metrics is 0 instead of 1.

Expected Result

Data point value of the emitted traces.span.metrics.calls metric should be 1 after each sent span

Actual Result

Data point value of the emitted traces.span.metrics.calls metric is 0 after each sent span

Collector version

v0.126.0

Environment information

No response

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318

connectors:
  spanmetrics:
    exclude_dimensions: 
      - span.name
      - span.kind
      - status.code
    metrics_flush_interval: 10s
    aggregation_temporality: AGGREGATION_TEMPORALITY_DELTA
    
exporters:
  file:
    path: /tmp/spanmetrics.json
service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [spanmetrics]
    metrics:
      receivers: [spanmetrics]
      exporters: [file]

Additional context

Proposed solution

I think we can check the aggregation type here so that we set the first value to 0 for cumulative metrics only. If my understanding is correct, the issue addressed by #39052 applies to cumulative metrics only.

@jsonlsy jsonlsy added bug Something isn't working needs triage New item requiring triage labels May 20, 2025
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@VihasMakwana
Copy link
Contributor

VihasMakwana commented May 20, 2025

Looks like a regression. Can you roll out a PR?

@VihasMakwana VihasMakwana removed the needs triage New item requiring triage label May 20, 2025
@jsonlsy
Copy link
Contributor Author

jsonlsy commented May 20, 2025

Yep, I can create a PR for the proposed solution. Let me know if there are any other ideas/thoughts.

dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this issue May 23, 2025
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description
Fixes bug causing calls count to always be 0 when using delta
aggregation temporality (see linked issue).

This PR adds a check for the temporality used so that we only overwrite
the first value for cumulative metrics only.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes
open-telemetry#40139

<!--Please delete paragraphs that you did not use before submitting.-->

---------

Co-authored-by: Sean Marciniak <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working connector/spanmetrics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants