Skip to content

Commit

Permalink
Remove build flags for runtime/trace support (#1498)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MrAlias authored Jan 29, 2021
1 parent 4bf4b69 commit ad7b471
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 59 deletions.
32 changes: 0 additions & 32 deletions sdk/trace/trace_go11.go

This file was deleted.

25 changes: 0 additions & 25 deletions sdk/trace/trace_nongo11.go

This file was deleted.

13 changes: 11 additions & 2 deletions sdk/trace/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package trace // import "go.opentelemetry.io/otel/sdk/trace"

import (
"context"
rt "runtime/trace"

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

ctx, end := startExecutionTracerTask(ctx, name)
span.executionTracerTaskEnd = end
ctx, span.executionTracerTaskEnd = func(ctx context.Context) (context.Context, func()) {
if !rt.IsEnabled() {
// Avoid additional overhead if
// runtime/trace is not enabled.
return ctx, func() {}
}
nctx, task := rt.NewTask(ctx, name)
return nctx, task.End
}(ctx)

return trace.ContextWithSpan(ctx, span), span
}

0 comments on commit ad7b471

Please sign in to comment.