Skip to content

fix: keep custom exemplar labels caller-controlled#2194

Merged
jaydeluca merged 1 commit into
prometheus:exemplar-labels-cleanfrom
zeitlinger:codex/fix-custom-exemplar-suppliers
Jun 5, 2026
Merged

fix: keep custom exemplar labels caller-controlled#2194
jaydeluca merged 1 commit into
prometheus:exemplar-labels-cleanfrom
zeitlinger:codex/fix-custom-exemplar-suppliers

Conversation

@zeitlinger
Copy link
Copy Markdown
Member

Summary

  • keep supplier-provided exemplar labels on the automatic sampling path only
  • preserve explicit custom exemplar labels as caller-controlled
  • update tests to cover the intended custom-exemplar behavior

Root cause

PR #2191 reused doSampleExemplar() from the custom exemplar path. After that method started merging per-metric and global label suppliers, incWithExemplar(...) and observeWithExemplar(...) also picked up supplier labels, even though the new API/docs describe that behavior for automatically-sampled exemplars only.

Impact

Custom exemplars remain explicitly controlled by the caller, while automatically-sampled exemplars still receive the configured extra labels.

Validation

  • mise run build
  • ./mvnw -q -pl prometheus-metrics-core -am -Dtest=CounterTest -Dsurefire.failIfNoSpecifiedTests=false test -Dcoverage.skip=true -Dcheckstyle.skip=true
  • mise run lint:fix

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
@zeitlinger zeitlinger marked this pull request as ready for review June 5, 2026 13:45
Copy link
Copy Markdown
Collaborator

@jaydeluca jaydeluca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice thanks

@jaydeluca jaydeluca merged commit efbcfb8 into prometheus:exemplar-labels-clean Jun 5, 2026
19 checks passed
jaydeluca pushed a commit that referenced this pull request Jun 5, 2026
Signed-off-by: Jay DeLuca <jaydeluca4@gmail.com>
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.

2 participants