| 1 |
// Copyright The OpenTelemetry Authors |
| 2 |
// SPDX-License-Identifier: Apache-2.0 |
| 3 |
|
| 4 |
package jaeger // import "go.opentelemetry.io/contrib/propagators/jaeger" |
| 5 |
|
| 6 |
import "context" |
| 7 |
|
| 8 |
type jaegerKeyType int |
| 9 |
|
| 10 |
const ( |
| 11 |
debugKey jaegerKeyType = iota |
| 12 |
) |
| 13 |
|
| 14 |
// withDebug returns a copy of parent with debug set as the debug flag value . |
| 15 |
func withDebug(parent context.Context, debug bool) context.Context { |
| 16 |
return context.WithValue(parent, debugKey, debug) |
| 17 |
} |
| 18 |
|
| 19 |
// debugFromContext returns the debug value stored in ctx. |
| 20 |
// |
| 21 |
// If no debug value is stored in ctx false is returned. |
| 22 |
func debugFromContext(ctx context.Context) bool { |
| 23 |
if ctx == nil { |
| 24 |
return false |
| 25 |
} |
| 26 |
if debug, ok := ctx.Value(debugKey).(bool); ok { |
| 27 |
return debug |
| 28 |
} |
| 29 |
return false |
| 30 |
} |