2020-03-23 22:41:10 -07:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2024-02-29 07:05:28 +01:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2019-09-25 08:12:22 +02:00
|
|
|
|
2020-11-04 18:10:58 +01:00
|
|
|
package migration // import "go.opentelemetry.io/otel/bridge/opentracing/migration"
|
2019-09-25 08:12:22 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type doDeferredContextSetupType struct{}
|
|
|
|
|
2023-03-07 05:40:31 -08:00
|
|
|
var (
|
|
|
|
doDeferredContextSetupTypeKey = doDeferredContextSetupType{}
|
|
|
|
doDeferredContextSetupTypeValue = doDeferredContextSetupType{}
|
|
|
|
)
|
|
|
|
|
2019-09-25 08:12:22 +02:00
|
|
|
// WithDeferredSetup returns a context that can tell the OpenTelemetry
|
|
|
|
// tracer to skip the context setup in the Start() function.
|
|
|
|
func WithDeferredSetup(ctx context.Context) context.Context {
|
2023-03-07 05:40:31 -08:00
|
|
|
return context.WithValue(ctx, doDeferredContextSetupTypeKey, doDeferredContextSetupTypeValue)
|
2019-09-25 08:12:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SkipContextSetup can tell the OpenTelemetry tracer to skip the
|
|
|
|
// context setup during the span creation in the Start() function.
|
|
|
|
func SkipContextSetup(ctx context.Context) bool {
|
2023-03-07 05:40:31 -08:00
|
|
|
_, ok := ctx.Value(doDeferredContextSetupTypeKey).(doDeferredContextSetupType)
|
2019-09-25 08:12:22 +02:00
|
|
|
return ok
|
|
|
|
}
|