1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

Add StartOptions to Tracer.WithSpan() (#472)

Tracer.WithSpan() will now accept StartOptions as a variadic final parameter `opts`
that will be passed to the Tracer.Start() invocation that creates the Span
wrapping the user-provided function.
This commit is contained in:
Anthony Mirabella
2020-02-10 21:07:32 -05:00
committed by GitHub
parent 0f1771f374
commit f0c70ffde0
9 changed files with 43 additions and 13 deletions

View File

@@ -66,8 +66,8 @@ func (tr *tracer) Start(ctx context.Context, name string, o ...apitrace.StartOpt
return apitrace.ContextWithSpan(ctx, span), span
}
func (tr *tracer) WithSpan(ctx context.Context, name string, body func(ctx context.Context) error) error {
ctx, span := tr.Start(ctx, name)
func (tr *tracer) WithSpan(ctx context.Context, name string, body func(ctx context.Context) error, opts ...apitrace.StartOption) error {
ctx, span := tr.Start(ctx, name, opts...)
defer span.End()
if err := body(ctx); err != nil {