diff --git a/CHANGELOG.md b/CHANGELOG.md index 496d7aca9878..db030344f244 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,7 +51,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - OTLP Metric exporter supports Histogram aggregation. (#1209) - The `Code` struct from the `go.opentelemetry.io/otel/codes` package now supports JSON marshaling and unmarshaling as well as implements the `Stringer` interface. (#1214) - A Baggage API to implement the OpenTelemetry specification. (#1217) -- Add Shutdown method to apitrace.TracerProvider (#1206) +- Add Shutdown method to sdk/trace/provider, shutdown processors in the order they were registered. (#1206) ### Changed diff --git a/bridge/opentracing/wrapper.go b/bridge/opentracing/wrapper.go index 207c36605aa2..4625f6f544e5 100644 --- a/bridge/opentracing/wrapper.go +++ b/bridge/opentracing/wrapper.go @@ -32,9 +32,6 @@ func (p *WrapperTracerProvider) Tracer(_ string, _ ...otel.TracerOption) otel.Tr return p.wTracer } -// Shutdown implements TracerProvider -func (p *WrapperTracerProvider) Shutdown() {} - // NewWrappedTracerProvider creates a new trace provider that creates a single // instance of WrapperTracer that wraps OpenTelemetry tracer. func NewWrappedTracerProvider(bridge *BridgeTracer, tracer otel.Tracer) *WrapperTracerProvider { diff --git a/global/internal/trace.go b/global/internal/trace.go index 25027fee580c..d74966c04652 100644 --- a/global/internal/trace.go +++ b/global/internal/trace.go @@ -92,12 +92,7 @@ func (p *tracerProvider) Tracer(name string, opts ...otel.TracerOption) otel.Tra return t } -// Shutdown implements TracerProvider. -func (p *tracerProvider) Shutdown() { - p.delegate.Shutdown() -} - -// tracer is a placeholder for a trace.Tracer. +// tracer is a placeholder for a otel.Tracer. // // All Tracer functionality is forwarded to a delegate once configured. // Otherwise, all functionality is forwarded to a NoopTracer. diff --git a/global/internal/trace_test.go b/global/internal/trace_test.go index 2cdf7edb4691..39baa07d2c0a 100644 --- a/global/internal/trace_test.go +++ b/global/internal/trace_test.go @@ -30,7 +30,6 @@ func TestTraceWithSDK(t *testing.T) { ctx := context.Background() gtp := global.TracerProvider() - defer gtp.Shutdown() tracer1 := gtp.Tracer("pre") // This is started before an SDK was registered and should be dropped. _, span1 := tracer1.Start(ctx, "span1") diff --git a/global/trace_test.go b/global/trace_test.go index 45abb34254c8..4482f4d04897 100644 --- a/global/trace_test.go +++ b/global/trace_test.go @@ -22,9 +22,7 @@ import ( "go.opentelemetry.io/otel/internal/trace/noop" ) -type testTracerProvider struct { - running bool -} +type testTracerProvider struct{} var _ otel.TracerProvider = &testTracerProvider{} @@ -32,26 +30,16 @@ func (*testTracerProvider) Tracer(_ string, _ ...otel.TracerOption) otel.Tracer return noop.Tracer } -func (tp *testTracerProvider) Shutdown() { - tp.running = false -} - func TestMultipleGlobalTracerProvider(t *testing.T) { p1 := testTracerProvider{} p2 := otel.NewNoopTracerProvider() - - global.SetTracerProvider(p2) global.SetTracerProvider(&p1) + global.SetTracerProvider(p2) got := global.TracerProvider() - p1.running = true - want := &p1 + want := p2 if got != want { t.Fatalf("TracerProvider: got %p, want %p\n", got, want) } - got.Shutdown() - if p1.running { - t.Fatalf("Trace should be shutdown") - } } diff --git a/oteltest/provider.go b/oteltest/provider.go index d0582d4257b2..4de1c356dda0 100644 --- a/oteltest/provider.go +++ b/oteltest/provider.go @@ -66,5 +66,3 @@ func (p *TracerProvider) Tracer(instName string, opts ...otel.TracerOption) otel } return t } - -func (p *TracerProvider) Shutdown() {} diff --git a/trace.go b/trace.go index cb1af117e994..edb95efa7f08 100644 --- a/trace.go +++ b/trace.go @@ -374,7 +374,4 @@ type TracerProvider interface { // instrumentationName is empty, then a implementation defined default // name will be used instead. Tracer(instrumentationName string, opts ...TracerOption) Tracer - - // Shutdown closes the provider's resources such as the span processors. - Shutdown() } diff --git a/trace_noop.go b/trace_noop.go index 2a7190a64c76..8e1483eddc22 100644 --- a/trace_noop.go +++ b/trace_noop.go @@ -37,9 +37,6 @@ func (p noopTracerProvider) Tracer(string, ...TracerOption) Tracer { return noopTracer{} } -// Shutdown returns noop implementation of Tracer. -func (p noopTracerProvider) Shutdown() {} - // noopTracer is an implementation of Tracer that preforms no operations. type noopTracer struct{}