From 77c1f363c5e072cc15b01c5bbb496d9cbba0b14f 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..c69ca05 100644 --- a/src/Profiler/DatadogProfiler.php +++ b/src/Profiler/DatadogProfiler.php @@ -4,6 +4,7 @@ namespace Sourceability\Instrumentation\Profiler; +use DDTrace\Tracer; use function dd_trace_env_config; use DDTrace\Contracts\Scope; use DDTrace\GlobalTracer; @@ -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