You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-05 00:28:58 +02:00
Add example for SetTextMapPropagator (#6579)
Example demonstrating how to use `SetTextMapPropagator` with a composite propagator Related Issue: Closes #6571 Co-authored-by: Damien Mathieu <42@dmathieu.com>
This commit is contained in:
20
propagation/example_test.go
Normal file
20
propagation/example_test.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright The OpenTelemetry Authors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
package propagation_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.opentelemetry.io/otel"
|
||||||
|
"go.opentelemetry.io/otel/propagation"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ExampleSetTextMapPropagator() {
|
||||||
|
// Create a new composite text map propagator.
|
||||||
|
propagator := propagation.NewCompositeTextMapPropagator(
|
||||||
|
propagation.TraceContext{},
|
||||||
|
propagation.Baggage{},
|
||||||
|
)
|
||||||
|
|
||||||
|
// Set it as the global text map propagator.
|
||||||
|
otel.SetTextMapPropagator(propagator)
|
||||||
|
}
|
Reference in New Issue
Block a user