mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-01-28 03:57:09 +02:00
Set default propagator to no-op propagator (#1204)
- add set propagator to examples Signed-off-by: Hui Kang <kangh@us.ibm.com> Co-authored-by: Anthony Mirabella <a9@aneurysm9.com> Co-authored-by: Anthony Mirabella <a9@aneurysm9.com>
This commit is contained in:
parent
04297f4d04
commit
423c891359
@ -12,6 +12,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||
|
||||
- OTLP Metric exporter supports Histogram aggregation. (#1209)
|
||||
|
||||
### Changed
|
||||
|
||||
- Set default propagator to no-op propagator. (#1184)
|
||||
|
||||
## [0.12.0] - 2020-09-24
|
||||
|
||||
### Added
|
||||
|
@ -18,11 +18,9 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"go.opentelemetry.io/otel/api/baggage"
|
||||
"go.opentelemetry.io/otel/api/metric"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/propagators"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -120,15 +118,9 @@ func defaultPropagatorsValue() *atomic.Value {
|
||||
return v
|
||||
}
|
||||
|
||||
// getDefaultPropagators returns a default Propagators, configured
|
||||
// with W3C trace and baggage propagation.
|
||||
// getDefaultPropagators returns a default noop Propagators
|
||||
func getDefaultPropagators() propagation.Propagators {
|
||||
tcPropagator := propagators.TraceContext{}
|
||||
bagPropagator := baggage.Baggage{}
|
||||
return propagation.New(
|
||||
propagation.WithExtractors(tcPropagator, bagPropagator),
|
||||
propagation.WithInjectors(tcPropagator, bagPropagator),
|
||||
)
|
||||
return propagation.New()
|
||||
}
|
||||
|
||||
// ResetForTest restores the initial global state, for testing purposes.
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"go.opentelemetry.io/otel/api/baggage"
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/metric"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
"go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/exporters/stdout"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
@ -61,6 +62,12 @@ func main() {
|
||||
global.SetTracerProvider(tp)
|
||||
global.SetMeterProvider(pusher.MeterProvider())
|
||||
|
||||
// set propagator to baggage since the default is no-op
|
||||
bagPropagator := baggage.DefaultHTTPPropagator()
|
||||
props := propagation.New(propagation.WithExtractors(bagPropagator),
|
||||
propagation.WithInjectors(bagPropagator))
|
||||
|
||||
global.SetPropagators(props)
|
||||
tracer := global.Tracer("ex.com/basic")
|
||||
meter := global.Meter("ex.com/basic")
|
||||
|
||||
|
@ -27,9 +27,11 @@ import (
|
||||
|
||||
"go.opentelemetry.io/otel/api/global"
|
||||
"go.opentelemetry.io/otel/api/metric"
|
||||
"go.opentelemetry.io/otel/api/propagation"
|
||||
apitrace "go.opentelemetry.io/otel/api/trace"
|
||||
"go.opentelemetry.io/otel/exporters/otlp"
|
||||
"go.opentelemetry.io/otel/label"
|
||||
"go.opentelemetry.io/otel/propagators"
|
||||
"go.opentelemetry.io/otel/sdk/metric/controller/push"
|
||||
"go.opentelemetry.io/otel/sdk/metric/processor/basic"
|
||||
"go.opentelemetry.io/otel/sdk/metric/selector/simple"
|
||||
@ -73,6 +75,10 @@ func initProvider() func() {
|
||||
push.WithPeriod(2*time.Second),
|
||||
)
|
||||
|
||||
tcPropagator := propagators.TraceContext{}
|
||||
props := propagation.New(propagation.WithExtractors(tcPropagator),
|
||||
propagation.WithInjectors(tcPropagator))
|
||||
global.SetPropagators(props)
|
||||
global.SetTracerProvider(tracerProvider)
|
||||
global.SetMeterProvider(pusher.MeterProvider())
|
||||
pusher.Start()
|
||||
|
Loading…
x
Reference in New Issue
Block a user