diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2bf3d0f79d7..ee86fa994e6 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -64,7 +64,7 @@ public function boot() $GLOBALS['cfg']['datadog-helper']['prefix_web'].'.queue.run', 1, [ - 'job' => $event->job->resolveName(), + 'job' => $event->job->payload()['data']['commandName'], 'queue' => $event->job->getQueue(), ] ); diff --git a/tests/Jobs/JobNameTest.php b/tests/Jobs/JobNameTest.php new file mode 100644 index 00000000000..e091de1d5df --- /dev/null +++ b/tests/Jobs/JobNameTest.php @@ -0,0 +1,28 @@ +. Licensed under the GNU Affero General Public License v3.0. +// See the LICENCE file in the repository root for full licence text. + +declare(strict_types=1); + +namespace Tests\Jobs; + +use Illuminate\Queue\Events\JobProcessed; +use Queue; +use Tests\TestCase; + +class JobNameTest extends TestCase +{ + public function testDisplayName() + { + $job = new TestJob('test'); + + Queue::after(function (JobProcessed $event) use ($job) { + $payload = $event->job->payload(); + $this->assertSame($job::class, $payload['data']['commandName']); + $this->assertSame($job->displayName(), $payload['displayName']); + }); + + dispatch($job); + } +} diff --git a/tests/Jobs/TestJob.php b/tests/Jobs/TestJob.php new file mode 100644 index 00000000000..c1d21bbd916 --- /dev/null +++ b/tests/Jobs/TestJob.php @@ -0,0 +1,27 @@ +. Licensed under the GNU Affero General Public License v3.0. +// See the LICENCE file in the repository root for full licence text. + +namespace Tests\Jobs; + +use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; + +class TestJob implements ShouldQueue +{ + use Queueable; + + public function __construct(private $name) + { + } + + public function displayName() + { + return $this->name; + } + + public function handle() + { + } +}