Skip to content

Commit

Permalink
Merge pull request #10325 from notbakaneko/es-document-type-datadog
Browse files Browse the repository at this point in the history
Include type of model being indexed when running EsDocument
  • Loading branch information
nanaya authored Jul 3, 2023
2 parents 620f9ec + 1f256cd commit 5e3d11a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/Jobs/EsDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace App\Jobs;

use Datadog;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
Expand Down Expand Up @@ -58,6 +59,7 @@ public function handle(): void

if ($model !== null) {
$model->esIndexDocument();
$this->incrementStat('index');

return;
}
Expand All @@ -66,5 +68,18 @@ public function handle(): void
$keyName = $model->getKeyName();
$model->setAttribute($keyName, $id);
$model->esDeleteDocument();
$this->incrementStat('delete');
}

private function incrementStat(string $action): void
{
Datadog::increment(
config('datadog-helper.prefix_web').'.es_document',
1,
[
'action' => $action,
'class' => $this->modelMeta['class'],
],
);
}
}

0 comments on commit 5e3d11a

Please sign in to comment.