From 8618736505e79c6f18f93a5140e07727c7a644e6 Mon Sep 17 00:00:00 2001 From: Allen Lai Date: Thu, 11 Jan 2024 10:55:44 -0800 Subject: [PATCH] update reset logic per lib recomendation --- src/Profiler/DatadogProfiler.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Profiler/DatadogProfiler.php b/src/Profiler/DatadogProfiler.php index 3abd790..ee01530 100644 --- a/src/Profiler/DatadogProfiler.php +++ b/src/Profiler/DatadogProfiler.php @@ -8,6 +8,7 @@ use DDTrace\Contracts\Scope; use DDTrace\GlobalTracer; use DDTrace\Tag; +use DDTrace\Tracer; use DDTrace\Type; use function ddtrace_config_app_name; use function ddtrace_config_trace_enabled; @@ -85,7 +86,13 @@ public function stopAndIgnore(): void return; } - GlobalTracer::get()->reset(); + $this->scope = null; + + // https://github.com/DataDog/dd-trace-php/issues/1533#issuecomment-1059211743 + ini_set('datadog.trace.enabled', '0'); + ini_set('datadog.trace.enabled', '1'); + + GlobalTracer::set(new Tracer()); } private function isEnabled(): bool