- 
                Notifications
    You must be signed in to change notification settings 
- Fork 167
Open
Labels
🐛 bugSomething isn't workingSomething isn't working
Description
Bug report
The trace_method() function suppresses exceptions that are thrown inside a prehook callback.
This leads to inconsistent behavior between environments with and without dd-trace (e.g., local development vs. production).
Problem was discovered in DrupalIntegration.php, an exception thrown from $themeRegistry->getRuntime() inside a traced Drupal\Core\Theme\ThemeManager::render method is silently swallowed when dd-trace is active.
This makes debugging and consistent behavior between environments difficult.
Code to reproduce the problem:
<?php
use DDTrace\SpanData;
use function DDTrace\trace_method;
class testClass {
  private string $message = 'default';
  public function print(): void {
    echo $this->message;
  }
  public function throwException(): void {
    $this->message = 'Exception was thrown';
    throw new RuntimeException('Hello there!');
  }
}
trace_method(
  'testClass',
  'print',
  [
    'prehook' => function (SpanData $span, $args) {
      $test_class = $this;
      assert($test_class instanceof testClass);
      $test_class->throwException();
    },
  ]
);
$test_class = new testClass();
$test_class->print();PHP version
8.3.21
Tracer or profiler version
1.13.0
Installed extensions
No response
Output of phpinfo()
No response
Upgrading from
No response
Metadata
Metadata
Assignees
Labels
🐛 bugSomething isn't workingSomething isn't working