diff --git a/CHANGELOG.md b/CHANGELOG.md index 02d31643d69..9890893fe6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - `Logger.Enabled` in `go.opentelemetry.io/otel/log` now accepts a newly introduced `EnabledParameters` type instead of `Record`. (#5791) - `FilterProcessor.Enabled` in `go.opentelemetry.io/otel/sdk/log/internal/x` now accepts `EnabledParameters` instead of `Record`. (#5791) - The `Record` type in `go.opentelemetry.io/otel/log` is no longer comparable. (#5847) +- Performance improvements for `recordingSpan` `SetAttributes`. (#5864) ### Deprecated diff --git a/sdk/trace/span.go b/sdk/trace/span.go index 2a993c12436..2ddd5518566 100644 --- a/sdk/trace/span.go +++ b/sdk/trace/span.go @@ -584,7 +584,7 @@ func (s *recordingSpan) Attributes() []attribute.KeyValue { func (s *recordingSpan) dedupeAttrs() { // Do not set a capacity when creating this map. Benchmark testing has // showed this to only add unused memory allocations in general use. - exists := make(map[attribute.Key]int) + exists := make(map[attribute.Key]int, len(s.attributes)) s.dedupeAttrsFromRecord(&exists) }