Skip to content

Commit

Permalink
fix: disabled with nil
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphg6 committed Feb 22, 2024
1 parent 5ef7f6f commit 52bba11
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,21 @@ func Middleware(serviceName string, opts ...Option) gin.HandlerFunc {
}

// GetTracer ...
func GetTracer(ctx context.Context) trace.Tracer {
func GetTracer(ctx context.Context) *trace.Tracer {
tracerInterface := ctx.Value(keyTracer)
return tracerInterface.(trace.Tracer)
if tracerInterface == nil {
return nil
}
return tracerInterface.(*trace.Tracer)
}

// GetRootSpan ...
func GetRootSpan(ctx context.Context) trace.Span {
func GetRootSpan(ctx context.Context) *trace.Span {
span := ctx.Value(keyRootSpan)
return span.(trace.Span)
if span == nil {
return nil
}
return span.(*trace.Span)
}

// Inject ...
Expand Down

0 comments on commit 52bba11

Please sign in to comment.