2023-05-09 18:19:48 +01:00
|
|
|
// Copyright The OpenTelemetry Authors
|
2024-04-11 10:46:18 +01:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2023-05-09 18:19:48 +01:00
|
|
|
|
|
|
|
package baggage // import "go.opentelemetry.io/otel/baggage"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"go.opentelemetry.io/otel/internal/baggage"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ContextWithBaggage returns a copy of parent with baggage.
|
|
|
|
func ContextWithBaggage(parent context.Context, b Baggage) context.Context {
|
|
|
|
// Delegate so any hooks for the OpenTracing bridge are handled.
|
|
|
|
return baggage.ContextWithList(parent, b.list)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContextWithoutBaggage returns a copy of parent with no baggage.
|
|
|
|
func ContextWithoutBaggage(parent context.Context) context.Context {
|
|
|
|
// Delegate so any hooks for the OpenTracing bridge are handled.
|
|
|
|
return baggage.ContextWithList(parent, nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
// FromContext returns the baggage contained in ctx.
|
|
|
|
func FromContext(ctx context.Context) Baggage {
|
|
|
|
// Delegate so any hooks for the OpenTracing bridge are handled.
|
|
|
|
return Baggage{list: baggage.ListFromContext(ctx)}
|
|
|
|
}
|