Semconv metric helper caller-slice mutation fix#7993
Merged
pellared merged 2 commits intoopen-telemetry:mainfrom Mar 4, 2026
Merged
Semconv metric helper caller-slice mutation fix#7993pellared merged 2 commits intoopen-telemetry:mainfrom
pellared merged 2 commits intoopen-telemetry:mainfrom
Conversation
9 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7993 +/- ##
=======================================
- Coverage 81.6% 81.6% -0.1%
=======================================
Files 304 304
Lines 23385 23385
=======================================
- Hits 19093 19089 -4
- Misses 3905 3907 +2
- Partials 387 389 +2 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Go semconv metric helper generation to avoid mutating caller-provided attrs backing arrays when required semantic attributes are appended, and includes regenerated v1.40.0 metric helper outputs.
Changes:
- Update the Weaver Go template to cap
attrscapacity before appending required attributes (attrs[:len(attrs):len(attrs)]). - Regenerate affected
semconv/v1.40.0/*conv/metric.gofiles to apply the new append behavior. - Replace direct
append(attrs, ...)patterns with the capacity-clamped variant across the regenerated outputs.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| semconv/templates/registry/go/instrument.j2 | Adjusts generated helper attribute merging to avoid mutating caller slices. |
| semconv/v1.40.0/azureconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/cicdconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/dbconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/dnsconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/genaiconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/httpconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/hwconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/k8sconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/mcpconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/messagingconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/openshiftconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/rpcconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
| semconv/v1.40.0/vcsconv/metric.go | Regenerated to use capacity-clamped attrs before appending required attrs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pellared
approved these changes
Mar 4, 2026
dmathieu
approved these changes
Mar 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses issue #7987 (issue (1)): generated semconv metric helpers should not risk mutating caller-provided
attrsbacking arrays when required attributes are appended.Update the generator logic to merge required-attribute using capacity clamping before append:
This guarantees append allocates a new backing array for the merged slice instead of writing into caller memory when there are attributes appended. It makes not allocations in the case attributes are not appended.