diff options
Diffstat (limited to 'internal/tracing/tracing.go')
-rw-r--r-- | internal/tracing/tracing.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/internal/tracing/tracing.go b/internal/tracing/tracing.go index 4ba7c2091..9b4d74c2d 100644 --- a/internal/tracing/tracing.go +++ b/internal/tracing/tracing.go @@ -11,19 +11,19 @@ type Tags map[string]any // StartSpan creates a new span with name and options (mostly tags). This function is a wrapper for // underlying tracing libraries. This method should only be used at the entrypoint of the program. -func StartSpan(ctx context.Context, spanName string, tags Tags) (opentracing.Span, context.Context) { - return opentracing.StartSpanFromContext(ctx, spanName, tagsToOpentracingTags(tags)...) +func StartSpan(ctx context.Context, spanName string, tags Tags, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context) { + return opentracing.StartSpanFromContext(ctx, spanName, tagsToOpentracingTags(opts, tags)...) } // StartSpanIfHasParent creates a new span if the context already has an existing span. This function // adds a simple validation to prevent orphan spans outside interested code paths. It returns a dummy // span, which acts as normal span, but does absolutely nothing and is not recorded later. -func StartSpanIfHasParent(ctx context.Context, spanName string, tags Tags) (opentracing.Span, context.Context) { +func StartSpanIfHasParent(ctx context.Context, spanName string, tags Tags, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context) { parent := opentracing.SpanFromContext(ctx) if parent == nil { return &NoopSpan{}, ctx } - return opentracing.StartSpanFromContext(ctx, spanName, tagsToOpentracingTags(tags)...) + return opentracing.StartSpanFromContext(ctx, spanName, tagsToOpentracingTags(opts, tags)...) } // DiscardSpanInContext discards the current active span from the context. This function is helpful @@ -36,8 +36,7 @@ func DiscardSpanInContext(ctx context.Context) context.Context { return opentracing.ContextWithSpan(ctx, nil) } -func tagsToOpentracingTags(tags Tags) []opentracing.StartSpanOption { - var opts []opentracing.StartSpanOption +func tagsToOpentracingTags(opts []opentracing.StartSpanOption, tags Tags) []opentracing.StartSpanOption { for key, value := range tags { opts = append(opts, opentracing.Tag{Key: key, Value: value}) } |