Skip to content

Commit

Permalink
Add Nexus tracing interceptor (#1844)
Browse files Browse the repository at this point in the history
  • Loading branch information
bergundy authored Feb 25, 2025
1 parent ab1c356 commit f3da1f5
Show file tree
Hide file tree
Showing 6 changed files with 382 additions and 43 deletions.
5 changes: 5 additions & 0 deletions contrib/opentelemetry/tracing_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ func (t *tracer) Options() interceptor.TracerOptions {
}

func (t *tracer) UnmarshalSpan(m map[string]string) (interceptor.TracerSpanRef, error) {
if _, ok := m["traceparent"]; !ok {
// If there is no span, return nothing, but don't error out. This is
// a legitimate place where a span does not exist in the headers
return nil, nil
}
ctx := t.options.TextMapPropagator.Extract(context.Background(), textMapCarrier(m))
spanCtx := trace.SpanContextFromContext(ctx)
if !spanCtx.IsValid() {
Expand Down
6 changes: 6 additions & 0 deletions contrib/opentracing/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package opentracing

import (
"context"
"errors"
"fmt"

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

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

0 comments on commit f3da1f5

Please sign in to comment.