diff --git a/core/trace/agent.go b/core/trace/agent.go index 2a2e8c37..59e0e23e 100644 --- a/core/trace/agent.go +++ b/core/trace/agent.go @@ -59,7 +59,13 @@ func StartAgent(c Config) { // StopAgent shuts down the span processors in the order they were registered. func StopAgent() { - _ = tp.Shutdown(context.Background()) + lock.Lock() + defer lock.Unlock() + + if tp != nil { + _ = tp.Shutdown(context.Background()) + tp = nil + } } func createExporter(c Config) (sdktrace.SpanExporter, error) {