Skip to content

Clear the state of the ObservationValidator - #7337

Merged
jonatan-ivanov merged 1 commit into
micrometer-metrics:mainfrom
jonatan-ivanov:clear-observation-validator
Mar 25, 2026
Merged

jonatan-ivanov merged 1 commit into
micrometer-metrics:mainfrom
jonatan-ivanov:clear-observation-validator

Conversation

@jonatan-ivanov

Copy link
Copy Markdown
Member

In gh-7295 a ThreadLocal was introduced and elements are only added to it, never removed.

Also, it was reported in gh-6713 that in some cases reusing TestObservationRegistry can trigger validation issues since the validator remembers all the low cardinality key-values that were recorded previously.

Both of the issues can be worked around by creating a new TestObservationRegistry instance, however in some cases clearing its memory might be more convenient.

See gh-7295
See gh-6713

In micrometer-metricsgh-7295 a ThreadLocal was introduced and elements are only added to
it, never removed.

Also, it was reported in micrometer-metricsgh-6713 that in some cases reusing
TestObservationRegistry can trigger validation issues since the
validator remembers all the low cardinality key-values that were
recorded previously.

Both of the issues can be worked around by creating a new
TestObservationRegistry instance, however in some cases clearing its
memory might be more convenient.

See micrometer-metricsgh-7295
See micrometer-metricsgh-6713
@jonatan-ivanov
jonatan-ivanov merged commit 27b9997 into micrometer-metrics:main Mar 25, 2026
11 checks passed
@jonatan-ivanov
jonatan-ivanov deleted the clear-observation-validator branch March 25, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants