diff --git a/sdk/trace/trace_go11.go b/sdk/trace/trace_go11.go deleted file mode 100644 index 51586a538209..000000000000 --- a/sdk/trace/trace_go11.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build go1.11 - -package trace // import "go.opentelemetry.io/otel/sdk/trace" - -import ( - "context" - rt "runtime/trace" -) - -func startExecutionTracerTask(ctx context.Context, name string) (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 -} diff --git a/sdk/trace/trace_nongo11.go b/sdk/trace/trace_nongo11.go deleted file mode 100644 index d794329a7298..000000000000 --- a/sdk/trace/trace_nongo11.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright The OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build !go1.11 - -package trace // import "go.opentelemetry.io/otel/sdk/trace" - -import ( - "context" -) - -func startExecutionTracerTask(ctx context.Context, name string) (context.Context, func()) { - return ctx, func() {} -} diff --git a/sdk/trace/tracer.go b/sdk/trace/tracer.go index c85f866fd685..8bc5109d9775 100644 --- a/sdk/trace/tracer.go +++ b/sdk/trace/tracer.go @@ -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" @@ -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 }