| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package migration // import "go.opentelemetry.io/otel/bridge/opentracing/migration" |
| 5 |
|
| 6 |
import ( |
| 7 |
"context" |
| 8 |
) |
| 9 |
|
| 10 |
type doDeferredContextSetupType struct{} |
| 11 |
|
| 12 |
var ( |
| 13 |
doDeferredContextSetupTypeKey = doDeferredContextSetupType{} |
| 14 |
doDeferredContextSetupTypeValue = doDeferredContextSetupType{} |
| 15 |
) |
| 16 |
|
| 17 |
// WithDeferredSetup returns a context that can tell the OpenTelemetry |
| 18 |
// tracer to skip the context setup in the Start() function. |
| 19 |
func WithDeferredSetup(ctx context.Context) context.Context { |
| 20 |
return context.WithValue(ctx, doDeferredContextSetupTypeKey, doDeferredContextSetupTypeValue) |
| 21 |
} |
| 22 |
|
| 23 |
// SkipContextSetup can tell the OpenTelemetry tracer to skip the |
| 24 |
// context setup during the span creation in the Start() function. |
| 25 |
func SkipContextSetup(ctx context.Context) bool { |
| 26 |
_, ok := ctx.Value(doDeferredContextSetupTypeKey).(doDeferredContextSetupType) |
| 27 |
return ok |
| 28 |
} |