Skip to content

spanmetrics: fall back to mapped attribute when no source_label matches - #7802

Open
buiducnhat wants to merge 2 commits into
grafana:mainfrom
buiducnhat:fix/3256-spanmetrics-dimension-mapping-fallback
Open

spanmetrics: fall back to mapped attribute when no source_label matches#7802
buiducnhat wants to merge 2 commits into
grafana:mainfrom
buiducnhat:fix/3256-spanmetrics-dimension-mapping-fallback

Conversation

@buiducnhat

Copy link
Copy Markdown

What this PR does:

When a span-metrics dimension_mappings entry's name matches an attribute that is already present on a span/resource (e.g. http_response_status_code), that value is now used as a fallback when none of the configured source_labels match.

Motivation: With a config like

dimension_mappings:
  - name: http_response_status_code
    source_labels: [http.status_code]

spans that still send the legacy http.status_code get their value remapped to http_response_status_code, but spans that have already migrated to the new attribute end up with an empty http_response_status_code label and land on a different metric series. This splits a single logical signal across two series and makes migration of instrumentation conventions painful.

Behaviour change: only when no source_label produced a value does the processor consult the attribute named dimension_mappings.name directly. Existing behaviour for spans that match a source_label is unchanged (no double-counting, no reordering).

Which issue(s) this PR fixes:
Fixes #3256

Checklist

  • Tests updated (TestSpanMetricsDimensionMappingIncludesMappedAttribute covers both the mapped and direct-attribute paths)
  • Documentation added (not applicable — behaviour now matches the documented intent of dimension_mappings)
  • Changelog entry added under .chloggen/

When a dimension_mapping's name matches an attribute that is already
present on a span/resource (e.g. http_response_status_code after
normalization), use that value as a fallback so spans carrying the new
convention are labelled consistently with spans that only have a legacy
source_label.

Fixes grafana#3256
@github-actions

Copy link
Copy Markdown
Contributor

Signed commits report

2 of 2 commits between main and fix/3256-spanmetrics-dimension-mapping-fallback could not be fully verified:

Commit Author Reason Message
5abd4bcb Nhat Bui unsigned spanmetrics: fall back to mapped attribute when no source_label matches
36fe1e9a Nhat Bui unsigned chore: add chloggen entry for #3256

This repository requires all commits to be signed. See GitHub docs on commit signature verification.

@cla-assistant

cla-assistant Bot commented Aug 20, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Aug 20, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

Span metrics dimension mappings should include non-mapped dimension as well

1 participant