generator: fix drain old series on metric replacement to prevent limi… - #6653
Merged
Conversation
…ter leak When a processor config change (dimensions, histogram buckets, etc.) triggers processor recreation, old metrics are replaced in the registry via registerMetric. Previously, the old metric's series were silently garbage-collected without calling OnDelete on the limiter, permanently inflating LocalSeriesLimiter.activeSeries. Each replacement accumulated more leaked counts, eventually pushing activeSeries above maxActiveSeries and trapping the tenant in permanent overflow. Drain all old series through removeStaleSeries before replacing the metric, which properly calls OnDelete for each series and decrements the limiter's counter.
carles-grafana
marked this pull request as ready for review
March 11, 2026 16:17
carles-grafana
requested review from
electron0zero,
ie-pham,
javiermolinar,
mapno,
mattdurham,
mdisibio,
oleg-kozlyuk-grafana,
ruslan-mikhailov,
stoewer,
yvrhdn and
zalegrala
as code owners
March 11, 2026 16:17
electron0zero
approved these changes
Mar 12, 2026
carles-grafana
pushed a commit
to carles-grafana/tempo
that referenced
this pull request
Mar 27, 2026
Add 3 entries that were missing from the unreleased changelog: - [BUGFIX] grafana#6774: target_info skipped when resource attributes have empty values - [BUGFIX] grafana#6653: drain old series on metric replacement to prevent limiter leak - [ENHANCEMENT] grafana#6371: make trace_too_large log line an insight
3 tasks
carles-grafana
added a commit
that referenced
this pull request
Mar 27, 2026
Add 3 entries that were missing from the unreleased changelog: - [BUGFIX] #6774: target_info skipped when resource attributes have empty values - [BUGFIX] #6653: drain old series on metric replacement to prevent limiter leak - [ENHANCEMENT] #6371: make trace_too_large log line an insight Co-authored-by: Carles Grafana <carles@grafana.com>
mattdurham
pushed a commit
to mattdurham/tempo
that referenced
this pull request
Jun 18, 2026
grafana#6653) * generator: fix drain old series on metric replacement to prevent limiter leak When a processor config change (dimensions, histogram buckets, etc.) triggers processor recreation, old metrics are replaced in the registry via registerMetric. Previously, the old metric's series were silently garbage-collected without calling OnDelete on the limiter, permanently inflating LocalSeriesLimiter.activeSeries. Each replacement accumulated more leaked counts, eventually pushing activeSeries above maxActiveSeries and trapping the tenant in permanent overflow. Drain all old series through removeStaleSeries before replacing the metric, which properly calls OnDelete for each series and decrements the limiter's counter. * fix lint: rename unused onAddFunc parameter to _ * remove unnecessary logging change, keep original log line * use math.MaxInt64 instead of time.Now().Add(time.Hour) for drain timestamp
mattdurham
pushed a commit
to mattdurham/tempo
that referenced
this pull request
Jun 18, 2026
Add 3 entries that were missing from the unreleased changelog: - [BUGFIX] grafana#6774: target_info skipped when resource attributes have empty values - [BUGFIX] grafana#6653: drain old series on metric replacement to prevent limiter leak - [ENHANCEMENT] grafana#6371: make trace_too_large log line an insight Co-authored-by: Carles Grafana <carles@grafana.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…ter leak
When a processor config change (dimensions, histogram buckets, etc.) triggers processor recreation, old metrics are replaced in the registry via registerMetric. Previously, the old metric's series were silently garbage-collected without calling OnDelete on the limiter, permanently inflating LocalSeriesLimiter.activeSeries. Each replacement accumulated more leaked counts, eventually pushing activeSeries above maxActiveSeries and trapping the tenant in permanent overflow.
Drain all old series through removeStaleSeries before replacing the metric, which properly calls OnDelete for each series and decrements the limiter's counter.
What this PR does:
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]