Skip to content

[connector/spanmetrics] Use latest semantic conventions for status code attribute#43000

Merged
atoulme merged 1 commit into
open-telemetry:mainfrom
Machyne:mc/spanmetrics
Nov 19, 2025
Merged

[connector/spanmetrics] Use latest semantic conventions for status code attribute#43000
atoulme merged 1 commit into
open-telemetry:mainfrom
Machyne:mc/spanmetrics

Conversation

@Machyne
Copy link
Copy Markdown
Contributor

@Machyne Machyne commented Sep 25, 2025

Description

Adds a feature gate to use the latest semantic conventions for the status code attribute on generated metrics. Changes:

Old Attribute New Attribute
status.code=STATUS_CODE_ERROR otel.status_code=ERROR
status.code=STATUS_CODE_OK otel.status_code=OK
status.code=STATUS_CODE_UNSET (no attribute)

Link to tracking issue

Partially Fixes #42103

Testing

Added new test case "Test using new status code attribute"

Documentation

README updated, changelog entry added

@Machyne Machyne requested a review from a team as a code owner September 25, 2025 22:40
@Machyne Machyne requested a review from crobert-1 September 25, 2025 22:40
@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Sep 25, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

Comment thread .chloggen/mc_spanmetrics.yaml Outdated
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe it's a breaking change

Comment thread .chloggen/mc_spanmetrics.yaml Outdated
component: spanmetricsconnector

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add a feature gate to use the latest semantic conventions for the status code attribute on generated metrics.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: We can use subtext to explain the rationale behind introducing this breaking change, as well as how to use feature gates to roll it back.

In note we explicitly say that the key of span status change from status.code to otel.status_code

if useOtelStatusCodeAttribute.IsEnabled() {
if !contains(p.config.ExcludeDimensions, otelStatusCodeKey) {
if span.Status().Code() == ptrace.StatusCodeError {
attr.PutStr(otelStatusCodeKey, "ERROR")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change also needs to be included in the changelog

Copy link
Copy Markdown
Contributor

@Frapschen Frapschen left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments.

@atoulme
Copy link
Copy Markdown
Contributor

atoulme commented Sep 28, 2025

Please address the changes and CI and mark ready for review again.

@atoulme atoulme marked this pull request as draft September 28, 2025 07:08
@Machyne Machyne marked this pull request as ready for review September 29, 2025 20:53
@obs-gh-mattcotter
Copy link
Copy Markdown
Contributor

@iblancasa would you mind reviewing as well? It looks like github is requiring two maintainer approvals

@Machyne
Copy link
Copy Markdown
Contributor Author

Machyne commented Oct 3, 2025

I think I misunderstood the issue; it seems like the workflows themselves need to be approved by a maintainer in order to run. @Frapschen would you be able to help with that? Or otherwise instruct on how to go about merging this if that isn't the blocker? Thank you!

@Machyne Machyne force-pushed the mc/spanmetrics branch 2 times, most recently from c0a8ab3 to 95dadeb Compare October 6, 2025 16:22
@Machyne
Copy link
Copy Markdown
Contributor Author

Machyne commented Oct 6, 2025

I'm not sure why the module check had failed. I rebased in hopes that it will solve the issue, but please let me know if it's otherwise actionable! I fixed the lint errors and the command the CI system had run: GOOS=linux GOARCH=amd64 make -j2 golint GROUP=connector now passes for me locally.

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Oct 6, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: Machyne / name: Matt Cotter (4fd36dc)

@obs-gh-mattcotter
Copy link
Copy Markdown
Contributor

Rebasing broke my new unit test since service.name was removed from the resource attributes with the new feature gate. I updated the test and it works again.

@Frapschen
Copy link
Copy Markdown
Contributor

@Machyne, I have tried to find an approver to approve the workflow to run.

@Frapschen
Copy link
Copy Markdown
Contributor

@Machyne Please resolve the conflicts

@Machyne
Copy link
Copy Markdown
Contributor Author

Machyne commented Oct 15, 2025

@Frapschen I rebased and pushed again!

@Frapschen
Copy link
Copy Markdown
Contributor

@Machyne Changelog check fail

@Machyne
Copy link
Copy Markdown
Contributor Author

Machyne commented Oct 16, 2025

@Frapschen sorry about that; the check must have been changed after I rebased. It's passing locally now.

"github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil"
)

var useOtelStatusCodeAttribute = featuregate.GlobalRegistry().MustRegister(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Machyne, can we move this to the factory.go?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Frapschen I made this update. Sorry for the delay, I had missed your message. I believe the prior windows failure was unrelated to my change. I ran the test and lint locally after my recent rebase and I'm hoping we can get this merged!

@Frapschen Frapschen added the ready to merge Code review completed; ready to merge by maintainers label Nov 7, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Nov 7, 2025

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

A maintainer will review your pull request soon. Thank you for helping make OpenTelemetry better!

@atoulme atoulme merged commit a74bad7 into open-telemetry:main Nov 19, 2025
205 of 206 checks passed
@github-actions github-actions Bot added this to the next release milestone Nov 19, 2025
@otelbot
Copy link
Copy Markdown
Contributor

otelbot Bot commented Nov 19, 2025

Thank you for your contribution @Machyne! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

codeboten pushed a commit that referenced this pull request May 15, 2026
#### Description
- Migrate programatically registered feature gates to `metadata.yaml`.
Kept comments/TODO intact as I assumed they were committed for a reason
in the first place.
- `from_version` for each gate was determined via `git describe
--contains <commit>` on the commit that introduced it:
  - `connector.spanmetrics.legacyMetricNames` → `v0.109.0` (#34485)
- `connector.spanmetrics.includeCollectorInstanceID` → `v0.136.0`
(#41865)
- `connector.spanmetrics.useSecondAsDefaultMetricsUnit` → `v0.137.0`
(#42761)
  - `connector.spanmetrics.excludeResourceMetrics` → `v0.137.0` (#42760)
- `spanmetrics.statusCodeConvention.useOtelPrefix` → `v0.141.0` (#43000)
- `spanmetrics.statusCodeConvention.useOtelPrefix` had no
`reference_url` in the original registration, so I used the implementing
PR as the reference URL as the issue was only partially fixed.
- `connector_test.go` already imports `google.golang.org/grpc/metadata`,
so the internal `metadata` package was imported with the alias
`spanmetricsmetadata` to avoid a name conflict

#### Link to tracking issue
Part of #46116

#### Testing
- `make` in the component directory
- `make gogci` in root dir

#### Documentation
- `connector/spanmetricsconnector/documentation.md` was generated via
`make generate`
ben-trans pushed a commit to ben-trans/opentelemetry-collector-contrib that referenced this pull request May 25, 2026
…ry#48281)

#### Description
- Migrate programatically registered feature gates to `metadata.yaml`.
Kept comments/TODO intact as I assumed they were committed for a reason
in the first place.
- `from_version` for each gate was determined via `git describe
--contains <commit>` on the commit that introduced it:
  - `connector.spanmetrics.legacyMetricNames` → `v0.109.0` (open-telemetry#34485)
- `connector.spanmetrics.includeCollectorInstanceID` → `v0.136.0`
(open-telemetry#41865)
- `connector.spanmetrics.useSecondAsDefaultMetricsUnit` → `v0.137.0`
(open-telemetry#42761)
  - `connector.spanmetrics.excludeResourceMetrics` → `v0.137.0` (open-telemetry#42760)
- `spanmetrics.statusCodeConvention.useOtelPrefix` → `v0.141.0` (open-telemetry#43000)
- `spanmetrics.statusCodeConvention.useOtelPrefix` had no
`reference_url` in the original registration, so I used the implementing
PR as the reference URL as the issue was only partially fixed.
- `connector_test.go` already imports `google.golang.org/grpc/metadata`,
so the internal `metadata` package was imported with the alias
`spanmetricsmetadata` to avoid a name conflict

#### Link to tracking issue
Part of open-telemetry#46116

#### Testing
- `make` in the component directory
- `make gogci` in root dir

#### Documentation
- `connector/spanmetricsconnector/documentation.md` was generated via
`make generate`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

connector/spanmetrics first-time contributor PRs made by new contributors ready to merge Code review completed; ready to merge by maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[connector/spanmetrics] improvements to config and schema of output RED metrics

7 participants