1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00
Files
opentelemetry-go/semconv/v1.40.0/httpconv
Tyler Yahn b2b3250897 Semconv metric helper caller-slice mutation fix (#7993)
This PR addresses issue #7987 (issue (1)): generated semconv metric
helpers should not risk mutating caller-provided `attrs` backing arrays
when required attributes are appended.

Update the generator logic to merge required-attribute using capacity
clamping before append:

```
append(attrs[:len(attrs):len(attrs)], requiredAttrs...)
```

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.
2026-03-04 15:49:49 +01:00
..