From 8530472ba574d796181e60ab3e129db56d7c5d17 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 31 Jul 2025 22:36:33 +0200 Subject: [PATCH 01/14] chore: enable exposedSyncMutex rule from go-critic Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - .../otellambda/lambdatest_test.go | 10 ++++----- .../mongo-driver/mongo/otelmongo/mongo.go | 10 ++++----- .../mongo-driver/v2/mongo/otelmongo/mongo.go | 10 ++++----- propagators/aws/xray/idgenerator.go | 10 ++++----- samplers/jaegerremote/sampler.go | 17 +++++++------- samplers/jaegerremote/sampler_remote.go | 14 ++++++------ zpages/spanprocessor.go | 22 +++++++++---------- 8 files changed, 46 insertions(+), 48 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9f3c0897527..5ad3f5dabf1 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -57,7 +57,6 @@ linters: disabled-checks: - appendAssign - exitAfterDefer - - exposedSyncMutex - hugeParam - unnamedResult - whyNoLint diff --git a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go index d34d6131596..4395388d898 100644 --- a/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go +++ b/instrumentation/github.com/aws/aws-lambda-go/otellambda/lambdatest_test.go @@ -35,22 +35,22 @@ import ( var errorLogger = log.New(log.Writer(), "OTel Lambda Test Error: ", 0) type mockIDGenerator struct { - sync.Mutex + mu sync.Mutex traceCount int spanCount int } func (m *mockIDGenerator) NewIDs(context.Context) (trace.TraceID, trace.SpanID) { - m.Lock() - defer m.Unlock() + m.mu.Lock() + defer m.mu.Unlock() m.traceCount++ m.spanCount++ return [16]byte{byte(m.traceCount)}, [8]byte{byte(m.spanCount)} } func (m *mockIDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { - m.Lock() - defer m.Unlock() + m.mu.Lock() + defer m.mu.Unlock() m.spanCount++ return [8]byte{byte(m.spanCount)} } diff --git a/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/mongo.go b/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/mongo.go index 53e100df1fe..58c01204c3a 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/mongo.go +++ b/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo/mongo.go @@ -23,7 +23,7 @@ type spanKey struct { } type monitor struct { - sync.Mutex + mu sync.Mutex spans map[spanKey]trace.Span cfg config semconv semconv.EventMonitor @@ -51,9 +51,9 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { ConnectionID: evt.ConnectionID, RequestID: evt.RequestID, } - m.Lock() + m.mu.Lock() m.spans[key] = span - m.Unlock() + m.mu.Unlock() } func (m *monitor) Succeeded(_ context.Context, evt *event.CommandSucceededEvent) { @@ -69,12 +69,12 @@ func (m *monitor) Finished(evt *event.CommandFinishedEvent, err error) { ConnectionID: evt.ConnectionID, RequestID: evt.RequestID, } - m.Lock() + m.mu.Lock() span, ok := m.spans[key] if ok { delete(m.spans, key) } - m.Unlock() + m.mu.Unlock() if !ok { return } diff --git a/instrumentation/go.mongodb.org/mongo-driver/v2/mongo/otelmongo/mongo.go b/instrumentation/go.mongodb.org/mongo-driver/v2/mongo/otelmongo/mongo.go index 4072a4c9949..d30e51a4c97 100644 --- a/instrumentation/go.mongodb.org/mongo-driver/v2/mongo/otelmongo/mongo.go +++ b/instrumentation/go.mongodb.org/mongo-driver/v2/mongo/otelmongo/mongo.go @@ -24,7 +24,7 @@ type spanKey struct { } type monitor struct { - sync.Mutex + mu sync.Mutex spans map[spanKey]trace.Span cfg config } @@ -59,9 +59,9 @@ func (m *monitor) Started(ctx context.Context, evt *event.CommandStartedEvent) { ConnectionID: evt.ConnectionID, RequestID: evt.RequestID, } - m.Lock() + m.mu.Lock() m.spans[key] = span - m.Unlock() + m.mu.Unlock() } func (m *monitor) Succeeded(_ context.Context, evt *event.CommandSucceededEvent) { @@ -77,12 +77,12 @@ func (m *monitor) Finished(evt *event.CommandFinishedEvent, err error) { ConnectionID: evt.ConnectionID, RequestID: evt.RequestID, } - m.Lock() + m.mu.Lock() span, ok := m.spans[key] if ok { delete(m.spans, key) } - m.Unlock() + m.mu.Unlock() if !ok { return } diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index df439448b57..00ab034e667 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -19,7 +19,7 @@ import ( // IDGenerator is used for generating a new traceID and spanID. type IDGenerator struct { - sync.Mutex + mu sync.Mutex randSource *rand.Rand } @@ -27,8 +27,8 @@ var _ sdktrace.IDGenerator = &IDGenerator{} // NewSpanID returns a non-zero span ID from a randomly-chosen sequence. func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { - gen.Lock() - defer gen.Unlock() + gen.mu.Lock() + defer gen.mu.Unlock() sid := trace.SpanID{} _, _ = gen.randSource.Read(sid[:]) return sid @@ -40,8 +40,8 @@ func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { // // span ID is from a randomly-chosen sequence. func (gen *IDGenerator) NewIDs(context.Context) (trace.TraceID, trace.SpanID) { - gen.Lock() - defer gen.Unlock() + gen.mu.Lock() + defer gen.mu.Unlock() tid := trace.TraceID{} currentTime := getCurrentTimeHex() diff --git a/samplers/jaegerremote/sampler.go b/samplers/jaegerremote/sampler.go index 259f7a669a7..ed4503e2719 100644 --- a/samplers/jaegerremote/sampler.go +++ b/samplers/jaegerremote/sampler.go @@ -209,8 +209,7 @@ func (*guaranteedThroughputProbabilisticSampler) Description() string { // perOperationSampler is a delegating sampler that applies guaranteedThroughputProbabilisticSampler // on a per-operation basis. type perOperationSampler struct { - sync.RWMutex - + mu sync.RWMutex samplers map[string]*guaranteedThroughputProbabilisticSampler defaultSampler *probabilisticSampler lowerBound float64 @@ -265,15 +264,15 @@ func (s *perOperationSampler) ShouldSample(p trace.SamplingParameters) trace.Sam } func (s *perOperationSampler) getSamplerForOperation(operation string) trace.Sampler { - s.RLock() + s.mu.RLock() sampler, ok := s.samplers[operation] if ok { - defer s.RUnlock() + defer s.mu.RUnlock() return sampler } - s.RUnlock() - s.Lock() - defer s.Unlock() + s.mu.RUnlock() + s.mu.Lock() + defer s.mu.Unlock() // Check if sampler has already been created sampler, ok = s.samplers[operation] @@ -294,8 +293,8 @@ func (*perOperationSampler) Description() string { } func (s *perOperationSampler) update(strategies *jaeger_api_v2.PerOperationSamplingStrategies) { - s.Lock() - defer s.Unlock() + s.mu.Lock() + defer s.mu.Unlock() newSamplers := map[string]*guaranteedThroughputProbabilisticSampler{} for _, strategy := range strategies.PerOperationStrategies { operation := strategy.Operation diff --git a/samplers/jaegerremote/sampler_remote.go b/samplers/jaegerremote/sampler_remote.go index bfe7e41287f..9e9817c4f66 100644 --- a/samplers/jaegerremote/sampler_remote.go +++ b/samplers/jaegerremote/sampler_remote.go @@ -72,7 +72,7 @@ type Sampler struct { // Cf. https://github.com/jaegertracing/jaeger-client-go/issues/155, https://pkg.go.dev/sync/atomic#pkg-note-BUG closed int64 // 0 - not closed, 1 - closed - sync.RWMutex // used to serialize access to samplerConfig.sampler + mu sync.RWMutex // used to serialize access to samplerConfig.sampler config serviceName string @@ -98,8 +98,8 @@ func New( // ShouldSample returns a sampling choice based on the passed sampling // parameters. func (s *Sampler) ShouldSample(p trace.SamplingParameters) trace.SamplingResult { - s.RLock() - defer s.RUnlock() + s.mu.RLock() + defer s.mu.RUnlock() return s.sampler.ShouldSample(p) } @@ -143,8 +143,8 @@ func (s *Sampler) pollControllerWithTicker(ticker *time.Ticker) { } func (s *Sampler) setSampler(sampler trace.Sampler) { - s.Lock() - defer s.Unlock() + s.mu.Lock() + defer s.mu.Unlock() s.sampler = sampler } @@ -162,8 +162,8 @@ func (s *Sampler) UpdateSampler() { return } - s.Lock() - defer s.Unlock() + s.mu.Lock() + defer s.mu.Unlock() if err := s.updateSamplerViaUpdaters(strategy); err != nil { s.logger.Error(err, "failed to handle sampling strategy response", "response", res) diff --git a/zpages/spanprocessor.go b/zpages/spanprocessor.go index 9480bda85d9..7837bfb4c26 100644 --- a/zpages/spanprocessor.go +++ b/zpages/spanprocessor.go @@ -154,9 +154,9 @@ func (ssm *SpanProcessor) spansByLatency(name string, latencyBucketIndex int) [] // It contains sample of spans for error requests (status code is codes.Error); // and a sample of spans for successful requests, bucketed by latency. type sampleStore struct { - sync.Mutex // protects everything below. - latency []*bucket - errors *bucket + mu sync.Mutex // protects everything below. + latency []*bucket + errors *bucket } // newSampleStore creates a sampleStore. @@ -172,8 +172,8 @@ func newSampleStore(latencyBucketSize, errorBucketSize uint) *sampleStore { } func (ss *sampleStore) perMethodSummary() *perMethodSummary { - ss.Lock() - defer ss.Unlock() + ss.mu.Lock() + defer ss.mu.Unlock() p := &perMethodSummary{} p.errorSpans = ss.errors.len() for _, b := range ss.latency { @@ -183,8 +183,8 @@ func (ss *sampleStore) perMethodSummary() *perMethodSummary { } func (ss *sampleStore) spansByLatency(latencyBucketIndex int) []sdktrace.ReadOnlySpan { - ss.Lock() - defer ss.Unlock() + ss.mu.Lock() + defer ss.mu.Unlock() if latencyBucketIndex < 0 || latencyBucketIndex >= len(ss.latency) { return nil } @@ -192,8 +192,8 @@ func (ss *sampleStore) spansByLatency(latencyBucketIndex int) []sdktrace.ReadOnl } func (ss *sampleStore) errorSpans() []sdktrace.ReadOnlySpan { - ss.Lock() - defer ss.Unlock() + ss.mu.Lock() + defer ss.mu.Unlock() return ss.errors.spans() } @@ -201,8 +201,8 @@ func (ss *sampleStore) errorSpans() []sdktrace.ReadOnlySpan { func (ss *sampleStore) sampleSpan(span sdktrace.ReadOnlySpan) { code := span.Status().Code - ss.Lock() - defer ss.Unlock() + ss.mu.Lock() + defer ss.mu.Unlock() if code == codes.Error { ss.errors.add(span) return From 6fedb8f679192bed2df8d93e4f9ed01ceafd6a65 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 13 Aug 2025 06:58:39 +0200 Subject: [PATCH 02/14] Expose mutex methods and deprecate their uses Signed-off-by: Matthieu MOREL --- propagators/aws/xray/idgenerator.go | 18 ++++++++++++++++++ samplers/jaegerremote/sampler_remote.go | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index 00ab034e667..97db02daab8 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -25,6 +25,24 @@ type IDGenerator struct { var _ sdktrace.IDGenerator = &IDGenerator{} +// Lock is used to lock the IDGenerator for concurrent use. +// Deprecated: mutex is internal and shall not be used. +func (gen *IDGenerator) Lock() { + gen.mu.Lock() +} + +// TryLock attempts to lock the IDGenerator for concurrent use. +// Deprecated: mutex is internal and shall not be used. +func (gen *IDGenerator) TryLock() bool { + return gen.mu.TryLock() +} + +// Unlock is used to unlock the IDGenerator for concurrent use. +// Deprecated: mutex is internal and shall not be used. +func (gen *IDGenerator) Unlock() { + gen.mu.Unlock() +} + // NewSpanID returns a non-zero span ID from a randomly-chosen sequence. func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { gen.mu.Lock() diff --git a/samplers/jaegerremote/sampler_remote.go b/samplers/jaegerremote/sampler_remote.go index 9e9817c4f66..0e4b074c39d 100644 --- a/samplers/jaegerremote/sampler_remote.go +++ b/samplers/jaegerremote/sampler_remote.go @@ -95,6 +95,24 @@ func New( return sampler } +// Lock is used to lock the Sampler for concurrent use. +// Deprecated: mutex is internal and shall not be used. +func (s *Sampler) Lock() { + s.mu.Lock() +} + +// TryLock attempts to lock the Sampler for concurrent use. +// Deprecated: mutex is internal and shall not be used. +func (s *Sampler) TryLock() bool { + return s.mu.TryLock() +} + +// Unlock is used to unlock the Sampler for concurrent use. +// Deprecated: mutex is internal and shall not be used. +func (s *Sampler) Unlock() { + s.mu.Unlock() +} + // ShouldSample returns a sampling choice based on the passed sampling // parameters. func (s *Sampler) ShouldSample(p trace.SamplingParameters) trace.SamplingResult { From c3c5d587f253c169ed1d962db979029b0738e8a0 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Wed, 13 Aug 2025 07:32:29 +0200 Subject: [PATCH 03/14] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flc゛ --- propagators/aws/xray/idgenerator.go | 3 +++ samplers/jaegerremote/sampler_remote.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index 97db02daab8..a4d719775e6 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -26,18 +26,21 @@ type IDGenerator struct { var _ sdktrace.IDGenerator = &IDGenerator{} // Lock is used to lock the IDGenerator for concurrent use. +// // Deprecated: mutex is internal and shall not be used. func (gen *IDGenerator) Lock() { gen.mu.Lock() } // TryLock attempts to lock the IDGenerator for concurrent use. +// // Deprecated: mutex is internal and shall not be used. func (gen *IDGenerator) TryLock() bool { return gen.mu.TryLock() } // Unlock is used to unlock the IDGenerator for concurrent use. +// // Deprecated: mutex is internal and shall not be used. func (gen *IDGenerator) Unlock() { gen.mu.Unlock() diff --git a/samplers/jaegerremote/sampler_remote.go b/samplers/jaegerremote/sampler_remote.go index 0e4b074c39d..34b3dcdf81a 100644 --- a/samplers/jaegerremote/sampler_remote.go +++ b/samplers/jaegerremote/sampler_remote.go @@ -96,18 +96,21 @@ func New( } // Lock is used to lock the Sampler for concurrent use. +// // Deprecated: mutex is internal and shall not be used. func (s *Sampler) Lock() { s.mu.Lock() } // TryLock attempts to lock the Sampler for concurrent use. +// // Deprecated: mutex is internal and shall not be used. func (s *Sampler) TryLock() bool { return s.mu.TryLock() } // Unlock is used to unlock the Sampler for concurrent use. +// // Deprecated: mutex is internal and shall not be used. func (s *Sampler) Unlock() { s.mu.Unlock() From 9f63fc33a6073800441a3b6be70566844547a64b Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Thu, 14 Aug 2025 11:34:05 +0000 Subject: [PATCH 04/14] update CHANGELOG Signed-off-by: Matthieu MOREL --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de0df621c57..fb21c18e9b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ The next release will require at least [Go 1.24]. - `Extract` and `Inject` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` are deprecated. These functions were initially exposed in the public API, but are now considered unnecessary. (#7689) - The `go.opentelemetry.io/contrib/detectors/aws/ec2` package is deprecated, use `go.opentelemetry.io/contrib/detectors/aws/ec2/v2` instead. (#7725) +- Deprecate direct exposure and usage of mutex objects via structs: introduce equivalent methods for locking/unlocking, and mark mutex fields as deprecated, specially for `go.opentelemetry.io/contrib/samplers/jaegerremote.Sampler` and `go.opentelemetry.io/contrib/propagators/aws/xray.IDGenerator`. (#7726) ### Removed From 2238e3b2f3df4d2aee13a7080845c3b9cf56cdd0 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Mon, 18 Aug 2025 08:32:37 +0000 Subject: [PATCH 05/14] make Mutex interfaces noop Signed-off-by: Matthieu MOREL --- propagators/aws/xray/idgenerator.go | 15 +++++++-------- samplers/jaegerremote/sampler_remote.go | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index a4d719775e6..2aea2eedbc9 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -26,25 +26,24 @@ type IDGenerator struct { var _ sdktrace.IDGenerator = &IDGenerator{} // Lock is used to lock the IDGenerator for concurrent use. +// noop method to satisfy the sync.Mutex interface. // // Deprecated: mutex is internal and shall not be used. -func (gen *IDGenerator) Lock() { - gen.mu.Lock() -} +func (*IDGenerator) Lock() {} // TryLock attempts to lock the IDGenerator for concurrent use. +// noop method to satisfy the sync.Mutex interface. // // Deprecated: mutex is internal and shall not be used. -func (gen *IDGenerator) TryLock() bool { - return gen.mu.TryLock() +func (*IDGenerator) TryLock() bool { + return false } // Unlock is used to unlock the IDGenerator for concurrent use. +// noop method to satisfy the sync.Mutex interface. // // Deprecated: mutex is internal and shall not be used. -func (gen *IDGenerator) Unlock() { - gen.mu.Unlock() -} +func (*IDGenerator) Unlock() {} // NewSpanID returns a non-zero span ID from a randomly-chosen sequence. func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID { diff --git a/samplers/jaegerremote/sampler_remote.go b/samplers/jaegerremote/sampler_remote.go index 34b3dcdf81a..fcb64d7db3a 100644 --- a/samplers/jaegerremote/sampler_remote.go +++ b/samplers/jaegerremote/sampler_remote.go @@ -96,25 +96,24 @@ func New( } // Lock is used to lock the Sampler for concurrent use. +// noop method to satisfy the sync.RWMutex interface. // // Deprecated: mutex is internal and shall not be used. -func (s *Sampler) Lock() { - s.mu.Lock() -} +func (*Sampler) Lock() {} // TryLock attempts to lock the Sampler for concurrent use. +// noop method to satisfy the sync.RWMutex interface. // // Deprecated: mutex is internal and shall not be used. -func (s *Sampler) TryLock() bool { - return s.mu.TryLock() +func (*Sampler) TryLock() bool { + return false } // Unlock is used to unlock the Sampler for concurrent use. +// noop method to satisfy the sync.RWMutex interface. // // Deprecated: mutex is internal and shall not be used. -func (s *Sampler) Unlock() { - s.mu.Unlock() -} +func (*Sampler) Unlock() {} // ShouldSample returns a sampling choice based on the passed sampling // parameters. From 46aa08a8c710b2292480086bdba73a4e04bc5005 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 16:15:21 +0200 Subject: [PATCH 06/14] Update CHANGELOG with deprecations and removals Deprecate direct usage of mutex objects and introduce methods for locking/unlocking. Mark mutex fields as deprecated for specific samplers and propagators. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8993c598c9..4599722e889 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] +### Deprecated + +- Deprecate direct exposure and usage of mutex objects via structs: introduce equivalent methods for locking/unlocking, and mark mutex fields as deprecated, specially for `go.opentelemetry.io/contrib/samplers/jaegerremote.Sampler` and `go.opentelemetry.io/contrib/propagators/aws/xray.IDGenerator`. (#7726) + ### Removed - Drop support for [Go 1.23]. (#7831) From c91a6e2600ff22e2b1341d9d9cd7d96e5df9b161 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 16:18:29 +0200 Subject: [PATCH 07/14] Deprecate mutex exposure and suggest alternatives Deprecate direct exposure of mutex objects and suggest methods for locking/unlocking. --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4599722e889..28dff6702fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,7 +61,6 @@ The next release will require at least [Go 1.24]. - `Extract` and `Inject` in `go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc` are deprecated. These functions were initially exposed in the public API, but are now considered unnecessary. (#7689) - The `go.opentelemetry.io/contrib/detectors/aws/ec2` package is deprecated, use `go.opentelemetry.io/contrib/detectors/aws/ec2/v2` instead. (#7725) -- Deprecate direct exposure and usage of mutex objects via structs: introduce equivalent methods for locking/unlocking, and mark mutex fields as deprecated, specially for `go.opentelemetry.io/contrib/samplers/jaegerremote.Sampler` and `go.opentelemetry.io/contrib/propagators/aws/xray.IDGenerator`. (#7726) ### Removed From f6c8f02a5c255a47ead10fa7b4ae37c80cb66333 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:27:22 +0200 Subject: [PATCH 08/14] Add deprecated mutex to IDGenerator struct --- propagators/aws/xray/idgenerator.go | 1 + 1 file changed, 1 insertion(+) diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index 2aea2eedbc9..c75a662927d 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -19,6 +19,7 @@ import ( // IDGenerator is used for generating a new traceID and spanID. type IDGenerator struct { + sync.Mutex // Deprecated: mutex is internal and shall not be used. mu sync.Mutex randSource *rand.Rand } From 0a4fb752ed51bd2a6df4bcc3ff1f3c89c3158310 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:28:25 +0200 Subject: [PATCH 09/14] Add deprecated mutex to perOperationSampler Added a deprecated mutex field to perOperationSampler struct. --- samplers/jaegerremote/sampler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/samplers/jaegerremote/sampler.go b/samplers/jaegerremote/sampler.go index ed4503e2719..b5eb002ca5f 100644 --- a/samplers/jaegerremote/sampler.go +++ b/samplers/jaegerremote/sampler.go @@ -209,6 +209,7 @@ func (*guaranteedThroughputProbabilisticSampler) Description() string { // perOperationSampler is a delegating sampler that applies guaranteedThroughputProbabilisticSampler // on a per-operation basis. type perOperationSampler struct { + sync.RWMutex // Deprecated: mutex is internal and shall not be used. mu sync.RWMutex samplers map[string]*guaranteedThroughputProbabilisticSampler defaultSampler *probabilisticSampler From e0fe00d61a9df72bfecc6d4417a174d798ce5c79 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:31:08 +0200 Subject: [PATCH 10/14] Add comment for ongoing deletion in sampler.go Add a comment indicating ongoing deletion of the perOperationSampler mutex. --- samplers/jaegerremote/sampler.go | 1 + 1 file changed, 1 insertion(+) diff --git a/samplers/jaegerremote/sampler.go b/samplers/jaegerremote/sampler.go index b5eb002ca5f..f55d9a762c7 100644 --- a/samplers/jaegerremote/sampler.go +++ b/samplers/jaegerremote/sampler.go @@ -209,6 +209,7 @@ func (*guaranteedThroughputProbabilisticSampler) Description() string { // perOperationSampler is a delegating sampler that applies guaranteedThroughputProbabilisticSampler // on a per-operation basis. type perOperationSampler struct { + //nolint:gocritic // ongoing deletion sync.RWMutex // Deprecated: mutex is internal and shall not be used. mu sync.RWMutex samplers map[string]*guaranteedThroughputProbabilisticSampler From bc456c2f5f412fea3dff88d2d29798a96e57bb04 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:32:44 +0200 Subject: [PATCH 11/14] Remove deprecated mutex comment in sampler.go --- samplers/jaegerremote/sampler.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/samplers/jaegerremote/sampler.go b/samplers/jaegerremote/sampler.go index f55d9a762c7..ed4503e2719 100644 --- a/samplers/jaegerremote/sampler.go +++ b/samplers/jaegerremote/sampler.go @@ -209,8 +209,6 @@ func (*guaranteedThroughputProbabilisticSampler) Description() string { // perOperationSampler is a delegating sampler that applies guaranteedThroughputProbabilisticSampler // on a per-operation basis. type perOperationSampler struct { - //nolint:gocritic // ongoing deletion - sync.RWMutex // Deprecated: mutex is internal and shall not be used. mu sync.RWMutex samplers map[string]*guaranteedThroughputProbabilisticSampler defaultSampler *probabilisticSampler From a794cea7ed51197a8762ea760d0ae8e82579cac8 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:33:42 +0200 Subject: [PATCH 12/14] Deprecate internal mutex in Sampler struct --- samplers/jaegerremote/sampler_remote.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/samplers/jaegerremote/sampler_remote.go b/samplers/jaegerremote/sampler_remote.go index 788bfb9f78a..aae8652646b 100644 --- a/samplers/jaegerremote/sampler_remote.go +++ b/samplers/jaegerremote/sampler_remote.go @@ -71,7 +71,8 @@ type Sampler struct { // These fields must be first in the struct because `sync/atomic` expects 64-bit alignment. // Cf. https://github.com/jaegertracing/jaeger-client-go/issues/155, https://pkg.go.dev/sync/atomic#pkg-note-BUG closed int64 // 0 - not closed, 1 - closed - + //nolint:gocritic // ongoing deletion + sync.RWMutex // Deprecated: mutex is internal and shall not be used. mu sync.RWMutex // used to serialize access to samplerConfig.sampler config From 84c9b64bc4357953029d6ba8aa9e790cd4a77d4e Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:35:06 +0200 Subject: [PATCH 13/14] Update propagators/aws/xray/idgenerator.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Robert Pająk --- propagators/aws/xray/idgenerator.go | 1 - 1 file changed, 1 deletion(-) diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index c75a662927d..1929427c554 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -20,7 +20,6 @@ import ( // IDGenerator is used for generating a new traceID and spanID. type IDGenerator struct { sync.Mutex // Deprecated: mutex is internal and shall not be used. - mu sync.Mutex randSource *rand.Rand } From d0061c785689c5899642bda667401b22f402c87f Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Tue, 9 Sep 2025 18:38:47 +0200 Subject: [PATCH 14/14] Add mutex field to IDGenerator struct --- propagators/aws/xray/idgenerator.go | 1 + 1 file changed, 1 insertion(+) diff --git a/propagators/aws/xray/idgenerator.go b/propagators/aws/xray/idgenerator.go index 1929427c554..c75a662927d 100644 --- a/propagators/aws/xray/idgenerator.go +++ b/propagators/aws/xray/idgenerator.go @@ -20,6 +20,7 @@ import ( // IDGenerator is used for generating a new traceID and spanID. type IDGenerator struct { sync.Mutex // Deprecated: mutex is internal and shall not be used. + mu sync.Mutex randSource *rand.Rand }