| Abhay Kumar | a2ae599 | 2025-11-10 14:02:24 +0000 | [diff] [blame^] | 1 | // Copyright The OpenTelemetry Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | package baggage // import "go.opentelemetry.io/otel/baggage" |
| 5 | |
| 6 | import ( |
| 7 | "context" |
| 8 | |
| 9 | "go.opentelemetry.io/otel/internal/baggage" |
| 10 | ) |
| 11 | |
| 12 | // ContextWithBaggage returns a copy of parent with baggage. |
| 13 | func ContextWithBaggage(parent context.Context, b Baggage) context.Context { |
| 14 | // Delegate so any hooks for the OpenTracing bridge are handled. |
| 15 | return baggage.ContextWithList(parent, b.list) |
| 16 | } |
| 17 | |
| 18 | // ContextWithoutBaggage returns a copy of parent with no baggage. |
| 19 | func ContextWithoutBaggage(parent context.Context) context.Context { |
| 20 | // Delegate so any hooks for the OpenTracing bridge are handled. |
| 21 | return baggage.ContextWithList(parent, nil) |
| 22 | } |
| 23 | |
| 24 | // FromContext returns the baggage contained in ctx. |
| 25 | func FromContext(ctx context.Context) Baggage { |
| 26 | // Delegate so any hooks for the OpenTracing bridge are handled. |
| 27 | return Baggage{list: baggage.ListFromContext(ctx)} |
| 28 | } |