tracing: return (ctx, span) from StartSpan
OpenTelemetry's Tracer#Start() returns (ctx, span). We have no reasons to swap them. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
parent
e751f1f44f
commit
cc59ae4d98
@ -77,7 +77,7 @@ func clientWithTrace() error {
|
||||
}
|
||||
defer cancel()
|
||||
|
||||
span, ctx := tracing.StartSpan(ctx, "OPERATION NAME")
|
||||
ctx, span := tracing.StartSpan(ctx, "OPERATION NAME")
|
||||
defer span.End()
|
||||
...
|
||||
}
|
||||
|
@ -24,13 +24,11 @@ import (
|
||||
)
|
||||
|
||||
// StartSpan starts child span in a context.
|
||||
func StartSpan(ctx context.Context, opName string, opts ...trace.SpanStartOption) (trace.Span, context.Context) {
|
||||
func StartSpan(ctx context.Context, opName string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
|
||||
if parent := trace.SpanFromContext(ctx); parent != nil && parent.SpanContext().IsValid() {
|
||||
ctx, span := parent.TracerProvider().Tracer("").Start(ctx, opName, opts...)
|
||||
return span, ctx
|
||||
return parent.TracerProvider().Tracer("").Start(ctx, opName, opts...)
|
||||
}
|
||||
ctx, span := otel.Tracer("").Start(ctx, opName, opts...)
|
||||
return span, ctx
|
||||
return otel.Tracer("").Start(ctx, opName, opts...)
|
||||
}
|
||||
|
||||
// StopSpan ends the span specified
|
||||
|
Loading…
Reference in New Issue
Block a user