Skip to content

Commit c624511

Browse files
committed
Expose mutex methods and deprecate their uses
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 5f26844 commit c624511

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

propagators/aws/xray/idgenerator.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ type IDGenerator struct {
2525

2626
var _ sdktrace.IDGenerator = &IDGenerator{}
2727

28+
// Lock is used to lock the IDGenerator for concurrent use.
29+
// Deprecated: mutex is internal and shall not be used.
30+
func (gen *IDGenerator) Lock() {
31+
gen.mu.Lock()
32+
}
33+
34+
// TryLock attempts to lock the IDGenerator for concurrent use.
35+
// Deprecated: mutex is internal and shall not be used.
36+
func (gen *IDGenerator) TryLock() bool {
37+
return gen.mu.TryLock()
38+
}
39+
40+
// Unlock is used to unlock the IDGenerator for concurrent use.
41+
// Deprecated: mutex is internal and shall not be used.
42+
func (gen *IDGenerator) Unlock() {
43+
gen.mu.Unlock()
44+
}
45+
2846
// NewSpanID returns a non-zero span ID from a randomly-chosen sequence.
2947
func (gen *IDGenerator) NewSpanID(context.Context, trace.TraceID) trace.SpanID {
3048
gen.mu.Lock()

samplers/jaegerremote/sampler_remote.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,24 @@ func New(
9595
return sampler
9696
}
9797

98+
// Lock is used to lock the Sampler for concurrent use.
99+
// Deprecated: mutex is internal and shall not be used.
100+
func (s *Sampler) Lock() {
101+
s.mu.Lock()
102+
}
103+
104+
// TryLock attempts to lock the Sampler for concurrent use.
105+
// Deprecated: mutex is internal and shall not be used.
106+
func (s *Sampler) TryLock() bool {
107+
return s.mu.TryLock()
108+
}
109+
110+
// Unlock is used to unlock the Sampler for concurrent use.
111+
// Deprecated: mutex is internal and shall not be used.
112+
func (s *Sampler) Unlock() {
113+
s.mu.Unlock()
114+
}
115+
98116
// ShouldSample returns a sampling choice based on the passed sampling
99117
// parameters.
100118
func (s *Sampler) ShouldSample(p trace.SamplingParameters) trace.SamplingResult {

0 commit comments

Comments
 (0)