Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use command name instead of display name in datadog metric #11165

Merged
merged 5 commits into from Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use a test to avoid getting trolled by laravel

'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()
{
}
}