From 849487a2f19dc6cfbce2a6fd1160e4dd2eaf9685 Mon Sep 17 00:00:00 2001 From: Mikhail Mazurskiy <126021+ash2k@users.noreply.github.com> Date: Wed, 6 Nov 2024 19:13:20 +1100 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert PajÄ…k --- sdk/metric/internal/aggregate/exemplar.go | 2 +- sdk/metric/pipeline.go | 4 ++-- sdk/trace/span.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/metric/internal/aggregate/exemplar.go b/sdk/metric/internal/aggregate/exemplar.go index 435462577dd..25d709948e9 100644 --- a/sdk/metric/internal/aggregate/exemplar.go +++ b/sdk/metric/internal/aggregate/exemplar.go @@ -17,7 +17,7 @@ var exemplarPool = sync.Pool{ func collectExemplars[N int64 | float64](out *[]metricdata.Exemplar[N], f func(*[]exemplar.Exemplar)) { dest := exemplarPool.Get().(*[]exemplar.Exemplar) defer func() { - clear(*dest) // Erase elements to let GC collect objects + clear(*dest) // Erase elements to let GC collect objects. *dest = (*dest)[:0] exemplarPool.Put(dest) }() diff --git a/sdk/metric/pipeline.go b/sdk/metric/pipeline.go index 6aa6426bf2a..563ef4b669a 100644 --- a/sdk/metric/pipeline.go +++ b/sdk/metric/pipeline.go @@ -115,7 +115,7 @@ func (p *pipeline) produce(ctx context.Context, rm *metricdata.ResourceMetrics) } if err := ctx.Err(); err != nil { rm.Resource = nil - clear(rm.ScopeMetrics) // Erase elements to let GC collect objects + clear(rm.ScopeMetrics) // Erase elements to let GC collect objects. rm.ScopeMetrics = rm.ScopeMetrics[:0] return err } @@ -129,7 +129,7 @@ func (p *pipeline) produce(ctx context.Context, rm *metricdata.ResourceMetrics) if err := ctx.Err(); err != nil { // This means the context expired before we finished running callbacks. rm.Resource = nil - clear(rm.ScopeMetrics) // Erase elements to let GC collect objects + clear(rm.ScopeMetrics) // Erase elements to let GC collect objects. rm.ScopeMetrics = rm.ScopeMetrics[:0] return err } diff --git a/sdk/trace/span.go b/sdk/trace/span.go index 4f1a6c76eb7..17f883c2c86 100644 --- a/sdk/trace/span.go +++ b/sdk/trace/span.go @@ -639,7 +639,7 @@ func (s *recordingSpan) dedupeAttrsFromRecord(record map[attribute.Key]int) { record[a.Key] = len(unique) - 1 } } - clear(s.attributes[len(unique):]) // Erase unneeded elements to let GC collect objects + clear(s.attributes[len(unique):]) // Erase unneeded elements to let GC collect objects. s.attributes = unique }