Skip to content

Commit f23f25a

Browse files
Add example for SetTextMapPropagator (#6579)
Example demonstrating how to use `SetTextMapPropagator` with a composite propagator Related Issue: Closes #6571 Co-authored-by: Damien Mathieu <[email protected]>
1 parent 1b32b1d commit f23f25a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

propagation/example_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright The OpenTelemetry Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package propagation_test
5+
6+
import (
7+
"go.opentelemetry.io/otel"
8+
"go.opentelemetry.io/otel/propagation"
9+
)
10+
11+
func ExampleSetTextMapPropagator() {
12+
// Create a new composite text map propagator.
13+
propagator := propagation.NewCompositeTextMapPropagator(
14+
propagation.TraceContext{},
15+
propagation.Baggage{},
16+
)
17+
18+
// Set it as the global text map propagator.
19+
otel.SetTextMapPropagator(propagator)
20+
}

0 commit comments

Comments
 (0)