Skip to content

Commit

Permalink
Merge pull request #11165 from notbakaneko/queue-datadog-log-command-…
Browse files Browse the repository at this point in the history
…name

Use command name instead of display name in datadog metric
  • Loading branch information
nanaya committed Apr 24, 2024
2 parents ab6120f + e1fbd38 commit aa9ef6d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Expand Up @@ -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(),
]
);
Expand Down
28 changes: 28 additions & 0 deletions tests/Jobs/JobNameTest.php
@@ -0,0 +1,28 @@
<?php

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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);
}
}
27 changes: 27 additions & 0 deletions tests/Jobs/TestJob.php
@@ -0,0 +1,27 @@
<?php

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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()
{
}
}

0 comments on commit aa9ef6d

Please sign in to comment.