diff --git a/src/Profiler/DatadogProfiler.php b/src/Profiler/DatadogProfiler.php index 3abd790..afd1246 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