Skip to content

Apply MeterFilters when building Kafka meter id for comparison#7569

Open
yoon-youngjin wants to merge 1 commit into
micrometer-metrics:1.16.xfrom
yoon-youngjin:fix/7541-kafka-metrics-meter-filter
Open

Apply MeterFilters when building Kafka meter id for comparison#7569
yoon-youngjin wants to merge 1 commit into
micrometer-metrics:1.16.xfrom
yoon-youngjin:fix/7541-kafka-metrics-meter-filter

Conversation

@yoon-youngjin

Copy link
Copy Markdown

Fixes gh-7541.

KafkaMetrics built the id used to compare against and remove already-registered meters from raw tags (plus a common-tags workaround), so configured MeterFilters that transform tags (replaceTagValues, renameTag, ...) made the comparison id diverge from the id the registry actually stores. As a result, stale meters were never removed.

This change routes the comparison id through MeterRegistry#getMappedId so all configured MeterFilters are applied, and drops the common-tags workaround. A regression test reproduces the issue with a replaceTagValues filter.

KafkaMetrics built the comparison id from raw tags (plus a common-tags hack), so MeterFilters that transform tags (replaceTagValues, renameTag, ...) made the comparison id diverge from the id the registry actually stores. Stale meters were then never removed

Route the comparison id through MeterRegistry#getMappedId so all configured MeterFilters are applied, and drop the common-tags workaround.

See micrometer-metricsgh-7541

Signed-off-by: yoon-youngjin <dudwls143@gmail.com>
@yoon-youngjin yoon-youngjin force-pushed the fix/7541-kafka-metrics-meter-filter branch from 99a9be7 to 69f48b7 Compare June 4, 2026 14:16
@yoon-youngjin

Copy link
Copy Markdown
Author

Hi @jonatan-ivanov, this is ready for review whenever you have a chance. It targets 1.16.x as requested and includes a regression test for the issue. CI and DCO are green. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant