From fb82c937ac2a0ec12a2e4bfd0f72838553ff37a9 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 15 Feb 2022 17:01:30 -0800 Subject: [PATCH 1/2] Fix race condition in reading the dropped spans number As any race condition this should be consider an undefined behavior, and a patch release should be done. Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 4 ++++ sdk/trace/batch_span_processor.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e124d10a9f..ee1d90237d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +### Fixed + +- Fix race condition in reading the dropped spans number (#2615) + ## [1.4.0] - 2022-02-11 ### Added diff --git a/sdk/trace/batch_span_processor.go b/sdk/trace/batch_span_processor.go index 6a7b9dc31bd..67e2732c3c7 100644 --- a/sdk/trace/batch_span_processor.go +++ b/sdk/trace/batch_span_processor.go @@ -250,7 +250,7 @@ func (bsp *batchSpanProcessor) exportSpans(ctx context.Context) error { } if l := len(bsp.batch); l > 0 { - global.Debug("exporting spans", "count", len(bsp.batch), "dropped", bsp.dropped) + global.Debug("exporting spans", "count", len(bsp.batch), "dropped", atomic.LoadUint32(&bsp.dropped)) err := bsp.e.ExportSpans(ctx, bsp.batch) // A new batch is always created after exporting, even if the batch failed to be exported. From a16ce671bc8532b1a0f0ee395981072f0914a63d Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 15 Feb 2022 17:27:30 -0800 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Tyler Yahn --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee1d90237d8..0fa8067bfbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Fixed -- Fix race condition in reading the dropped spans number (#2615) +- Fix race condition in reading the dropped spans number. (#2615) ## [1.4.0] - 2022-02-11