Skip to content

Commit ad7b471

Browse files
authored
Remove build flags for runtime/trace support (#1498)
The minimum version of Go this project supports is 1.14 meaning that all supported versions of Go support the runtime/trace package. Remove specific build overrides for versions of Go prior to 1.11 that are not supported by this project.
1 parent 4bf4b69 commit ad7b471

File tree

3 files changed

+11
-59
lines changed

3 files changed

+11
-59
lines changed

sdk/trace/trace_go11.go

-32
This file was deleted.

sdk/trace/trace_nongo11.go

-25
This file was deleted.

sdk/trace/tracer.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package trace // import "go.opentelemetry.io/otel/sdk/trace"
1616

1717
import (
1818
"context"
19+
rt "runtime/trace"
1920

2021
"go.opentelemetry.io/otel/internal/trace/parent"
2122
"go.opentelemetry.io/otel/trace"
@@ -65,7 +66,15 @@ func (tr *tracer) Start(ctx context.Context, name string, options ...trace.SpanO
6566
}
6667
}
6768

68-
ctx, end := startExecutionTracerTask(ctx, name)
69-
span.executionTracerTaskEnd = end
69+
ctx, span.executionTracerTaskEnd = func(ctx context.Context) (context.Context, func()) {
70+
if !rt.IsEnabled() {
71+
// Avoid additional overhead if
72+
// runtime/trace is not enabled.
73+
return ctx, func() {}
74+
}
75+
nctx, task := rt.NewTask(ctx, name)
76+
return nctx, task.End
77+
}(ctx)
78+
7079
return trace.ContextWithSpan(ctx, span), span
7180
}

0 commit comments

Comments
 (0)