@@ -24,13 +24,9 @@ import (
2424 "context"
2525
2626 "github.com/opentracing/opentracing-go"
27+ "go.uber.org/zap"
2728)
2829
29- // NewTracingContextPropagator returns new tracing context propagator object
30- func NewTracingContextPropagator (tracer opentracing.Tracer ) ContextPropagator {
31- return & tracingContextPropagator {tracer }
32- }
33-
3430type tracingReader struct {
3531 reader HeaderReader
3632}
@@ -62,16 +58,23 @@ func (t tracingWriter) Set(key, val string) {
6258// the header and puts it in the Context object. Does not start a new span
6359// as that is started outside when the workflow is actually executed
6460type tracingContextPropagator struct {
61+ logger * zap.Logger
6562 tracer opentracing.Tracer
6663}
6764
65+ // NewTracingContextPropagator returns new tracing context propagator object
66+ func NewTracingContextPropagator (logger * zap.Logger , tracer opentracing.Tracer ) ContextPropagator {
67+ return & tracingContextPropagator {logger , tracer }
68+ }
69+
6870func (t * tracingContextPropagator ) Inject (
6971 ctx context.Context ,
7072 hw HeaderWriter ,
7173) error {
7274 // retrieve span from context object
7375 span := opentracing .SpanFromContext (ctx )
7476 if span == nil {
77+ t .logger .Info ("could not retrieve span from context" )
7578 return nil
7679 }
7780 return t .tracer .Inject (span .Context (), opentracing .TextMap , tracingWriter {hw })
@@ -84,6 +87,7 @@ func (t *tracingContextPropagator) Extract(
8487 spanContext , err := t .tracer .Extract (opentracing .TextMap , tracingReader {hr })
8588 if err != nil {
8689 // did not find a tracing span, just return the current context
90+ t .logger .Info ("could not extract span information" , zap .Error (err ))
8791 return ctx , nil
8892 }
8993 return context .WithValue (ctx , activeSpanContextKey , spanContext ), nil
@@ -96,6 +100,7 @@ func (t *tracingContextPropagator) InjectFromWorkflow(
96100 // retrieve span from context object
97101 spanContext := spanFromContext (ctx )
98102 if spanContext == nil {
103+ t .logger .Info ("could not retrieve span from context" )
99104 return nil
100105 }
101106 return t .tracer .Inject (spanContext , opentracing .HTTPHeaders , tracingWriter {hw })
@@ -108,6 +113,7 @@ func (t *tracingContextPropagator) ExtractToWorkflow(
108113 spanContext , err := t .tracer .Extract (opentracing .TextMap , tracingReader {hr })
109114 if err != nil {
110115 // did not find a tracing span, just return the current context
116+ t .logger .Info ("could not extract span information" , zap .Error (err ))
111117 return ctx , nil
112118 }
113119 return contextWithSpan (ctx , spanContext ), nil
0 commit comments