Skip to content

[connector/spanmetrics] Skip resource iteration in resetState when nothing needs resetting - #50925

Open
KimMJ wants to merge 2 commits into
open-telemetry:mainfrom
KimMJ:KimMJ/spanmetrics-resetstate-guard
Open

[connector/spanmetrics] Skip resource iteration in resetState when nothing needs resetting#50925
KimMJ wants to merge 2 commits into
open-telemetry:mainfrom
KimMJ:KimMJ/spanmetrics-resetstate-guard

Conversation

@KimMJ

@KimMJ KimMJ commented Sep 11, 2026

Copy link
Copy Markdown

Description

p.config.Histogram.Disable condition in resetState() function becomes stale from #32210 change. This makes p.config.Histogram.Disable condition as no-ops, cause m.histograms.ClearExemplars() is called only when p.config.Exemplars.Enabled && !p.config.Histogram.Disable. So when histogram is enabled (default) and exemplar is disabled (default), early return is false and need to loop through resource cache even though iteration doesn't call clearing exemplar.

Link to tracking issue

N/A. Found small issue during investigation and create PR since it is small fix.

Testing

created minimal test case. confirmed it failed before change, passed after change.

before

$ go test -count=1 -run TestResetStateSkipsIterationWhenNothingToReset -v .
=== RUN   TestResetStateSkipsIterationWhenNothingToReset
    connector_test.go:1443:
                Error Trace:    /opentelemetry-collector-contrib/connector/spanmetricsconnector/connector_test.go:1443
                Error:          Should be zero, but was 1
                Test:           TestResetStateSkipsIterationWhenNothingToReset
--- FAIL: TestResetStateSkipsIterationWhenNothingToReset (0.00s)
FAIL
FAIL    github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector        1.835s
FAIL

after

$ go test -count=1 -run TestResetStateSkipsIterationWhenNothingToReset -v .
=== RUN   TestResetStateSkipsIterationWhenNothingToReset
--- PASS: TestResetStateSkipsIterationWhenNothingToReset (0.00s)
PASS
ok      github.com/open-telemetry/opentelemetry-collector-contrib/connector/spanmetricsconnector        2.387s

Documentation

No update.

Authorship

  • I, a human, wrote this pull request description myself.

…thing needs resetting

The early-return guard in resetState still required Histogram.Disable,
but since open-telemetry#32210 histograms only add work to the loop when exemplars are
enabled. With the default configuration (cumulative, histograms enabled,
exemplars off, no expiration) every flush iterated over all cached
resources under the connector lock without doing anything.

Drop the Histogram.Disable condition so the loop only runs when exemplar
clearing, series expiration or metrics expiration is configured.

Assisted-by: Claude Opus 5
@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Sep 11, 2026
Assisted-by: Claude Opus 5
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • Follow the OpenTelemetry Generative AI policy: disclose any AI use in your contribution, and communicate (PR descriptions, review replies) in your own words rather than AI-generated text.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help with general setup, development process, or contributor etiquette, ask in #opentelemetry-new-contributors.
  • First-time contributors should keep at most one PR marked as ready for review until their first PR is merged; once two are open for review, any further PR is automatically converted to draft.
  • If your change isn't one of our priority components, reviews may take more time.
  • Raise technical or Collector-specific questions in #otel-collector-dev or a Collector SIG meeting.

@KimMJ
KimMJ marked this pull request as ready for review September 11, 2026 16:40
@KimMJ
KimMJ requested review from a team and iblancasa as code owners September 11, 2026 16:40
@singhvibhanshu

Copy link
Copy Markdown
Member

/workflow-approve

@KimMJ

KimMJ commented Sep 12, 2026

Copy link
Copy Markdown
Author

/rerun

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-12 04:39 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants