From af45202acbd629f30a1e5044f8104d96536d5cfc Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Sat, 5 Mar 2016 20:47:50 -0500 Subject: [PATCH 1/2] Fix naming of DelegatorCarrier format --- tracer.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tracer.go b/tracer.go index 4c7433b03667..2c6fe223b118 100644 --- a/tracer.go +++ b/tracer.go @@ -188,10 +188,10 @@ func (t *tracerImpl) startSpanInternal( return sp } -type accessorType struct{} +type delegatorType struct{} -// Accessor is the format to use for AccessorCarrier. -var Accessor accessorType +// Delegator is the format to use for DelegatingCarrier. +var Delegator delegatorType func (t *tracerImpl) Inject(sp opentracing.Span, format interface{}, carrier interface{}) error { switch format { @@ -202,7 +202,7 @@ func (t *tracerImpl) Inject(sp opentracing.Span, format interface{}, carrier int case opentracing.GoHTTPHeader: return t.goHTTPPropagator.Inject(sp, carrier) } - if _, ok := format.(accessorType); ok { + if _, ok := format.(delegatorType); ok { return t.accessorPropagator.Inject(sp, carrier) } return opentracing.ErrUnsupportedFormat @@ -217,7 +217,7 @@ func (t *tracerImpl) Join(operationName string, format interface{}, carrier inte case opentracing.GoHTTPHeader: return t.goHTTPPropagator.Join(operationName, carrier) } - if _, ok := format.(accessorType); ok { + if _, ok := format.(delegatorType); ok { return t.accessorPropagator.Join(operationName, carrier) } return nil, opentracing.ErrUnsupportedFormat From 9687a122022d1cb269a556b9ed55820a40dd607d Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Sat, 5 Mar 2016 21:15:19 -0500 Subject: [PATCH 2/2] Make sure onBaggage is called for trimmed Spans and clarify the semantics. --- span.go | 2 +- tracer.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/span.go b/span.go index 24f98f2aa429..feac9dd8af55 100644 --- a/span.go +++ b/span.go @@ -136,6 +136,7 @@ func (s *spanImpl) SetBaggageItem(restrictedKey, val string) opentracing.Span { s.Lock() defer s.Unlock() + s.onBaggage(canonicalKey, val) if s.trim() { return s } @@ -144,7 +145,6 @@ func (s *spanImpl) SetBaggageItem(restrictedKey, val string) opentracing.Span { s.raw.Baggage = make(map[string]string) } s.raw.Baggage[canonicalKey] = val - s.onBaggage(canonicalKey, val) return s } diff --git a/tracer.go b/tracer.go index 2c6fe223b118..eb81773829d5 100644 --- a/tracer.go +++ b/tracer.go @@ -21,7 +21,8 @@ type Options struct { ShouldSample func(int64) bool // TrimUnsampledSpans turns potentially expensive operations on unsampled // Spans into no-ops. More precisely, tags, baggage items, and log events - // are silently discarded. + // are silently discarded. If NewSpanEventListener is set, the callbacks + // will still fire in that case. TrimUnsampledSpans bool // Recorder receives Spans which have been finished. Recorder SpanRecorder