Skip to content

Commit f3da1f5

Browse files
authored
Add Nexus tracing interceptor (#1844)
1 parent ab1c356 commit f3da1f5

File tree

6 files changed

+382
-43
lines changed

6 files changed

+382
-43
lines changed

contrib/opentelemetry/tracing_interceptor.go

+5
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ func (t *tracer) Options() interceptor.TracerOptions {
148148
}
149149

150150
func (t *tracer) UnmarshalSpan(m map[string]string) (interceptor.TracerSpanRef, error) {
151+
if _, ok := m["traceparent"]; !ok {
152+
// If there is no span, return nothing, but don't error out. This is
153+
// a legitimate place where a span does not exist in the headers
154+
return nil, nil
155+
}
151156
ctx := t.options.TextMapPropagator.Extract(context.Background(), textMapCarrier(m))
152157
spanCtx := trace.SpanContextFromContext(ctx)
153158
if !spanCtx.IsValid() {

contrib/opentracing/interceptor.go

+6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package opentracing
2525

2626
import (
2727
"context"
28+
"errors"
2829
"fmt"
2930

3031
"github.com/opentracing/opentracing-go"
@@ -111,6 +112,11 @@ func (t *tracer) Options() interceptor.TracerOptions {
111112

112113
func (t *tracer) UnmarshalSpan(m map[string]string) (interceptor.TracerSpanRef, error) {
113114
ctx, err := t.options.Tracer.Extract(opentracing.TextMap, opentracing.TextMapCarrier(m))
115+
if errors.Is(err, opentracing.ErrSpanContextNotFound) {
116+
// If there is no span, return nothing, but don't error out. This is
117+
// a legitimate place where a span does not exist in the headers
118+
return nil, nil
119+
}
114120
if err != nil {
115121
return nil, err
116122
}

0 commit comments

Comments
 (0)