DataDog / dd-trace-php

Datadog PHP Clients
https://docs.datadoghq.com/tracing/setup/php
Other
485 stars 151 forks source link

[Bug]: Laravel $dontReport does not have any affect on CLI #2784

Open lifeofguenter opened 1 month ago

lifeofguenter commented 1 month ago

Bug report

In Laravel it is possible to ignore certain Exceptions: https://laravel.com/docs/10.x/errors#ignoring-exceptions-by-type

Many are also already ignored by default, such as "ModelNotFoundException": https://github.com/laravel/framework/blob/11.x/src/Illuminate/Foundation/Exceptions/Handler.php#L146

This works for web requests in APM, but for CLI requests those exceptions still get recorded.

PHP version

8.3.10

Tracer or profiler version

1.2.0

Installed extensions

No response

Output of phpinfo()

No response

Upgrading from

No response

pablomartinezbernardo commented 1 month ago

Hey, thanks for this!

Tested this with Laravel 11 by adding an exception to the dontReport list, and running a cli command that triggers that exception: The spans are generated and the error is ignored as expected.

->withExceptions(function (Exceptions $exceptions) {
        $exceptions->dontReport([
            Symfony\Component\Console\Exception\NamespaceNotFoundException::class,
        ]);

What version of laravel are you using? Are you manually ignoring more exceptions than the default ones? What is different between your expectations and the spans being generated?