From 41ffa0a89937c230fa5ec227f252ac16ce9d18e5 Mon Sep 17 00:00:00 2001 From: bakaneko Date: Mon, 3 Jul 2023 13:35:25 +0900 Subject: [PATCH 1/3] log metric for type of document being indexed --- app/Jobs/EsDocument.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/Jobs/EsDocument.php b/app/Jobs/EsDocument.php index e0e4284200e..b1859efb401 100644 --- a/app/Jobs/EsDocument.php +++ b/app/Jobs/EsDocument.php @@ -7,6 +7,7 @@ namespace App\Jobs; +use Datadog; use Exception; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; @@ -58,6 +59,7 @@ public function handle(): void if ($model !== null) { $model->esIndexDocument(); + static::incrementStat('index', $this->modelMeta['class']); return; } @@ -66,5 +68,18 @@ public function handle(): void $keyName = $model->getKeyName(); $model->setAttribute($keyName, $id); $model->esDeleteDocument(); + static::incrementStat('delete', get_class($model)); + } + + private static function incrementStat(string $action, string $class) + { + Datadog::increment( + config('datadog-helper.prefix_web').'.es_document', + 1, + [ + 'action' => $action, + 'class' => $class, + ], + ); } } From 452784d0d699e883090823871d5338021da34da3 Mon Sep 17 00:00:00 2001 From: bakaneko Date: Mon, 3 Jul 2023 18:26:51 +0900 Subject: [PATCH 2/3] get_class(null) isn't supposed to work anyway --- app/Jobs/EsDocument.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Jobs/EsDocument.php b/app/Jobs/EsDocument.php index b1859efb401..78a92b45b56 100644 --- a/app/Jobs/EsDocument.php +++ b/app/Jobs/EsDocument.php @@ -59,7 +59,7 @@ public function handle(): void if ($model !== null) { $model->esIndexDocument(); - static::incrementStat('index', $this->modelMeta['class']); + static::incrementStat('index'); return; } @@ -68,17 +68,17 @@ public function handle(): void $keyName = $model->getKeyName(); $model->setAttribute($keyName, $id); $model->esDeleteDocument(); - static::incrementStat('delete', get_class($model)); + static::incrementStat('delete'); } - private static function incrementStat(string $action, string $class) + private function incrementStat(string $action): void { Datadog::increment( config('datadog-helper.prefix_web').'.es_document', 1, [ 'action' => $action, - 'class' => $class, + 'class' => $this->modelMeta['class'], ], ); } From 90c26435f3cb190c2d6ee0a5c383d4d2ab880282 Mon Sep 17 00:00:00 2001 From: bakaneko Date: Mon, 3 Jul 2023 18:27:46 +0900 Subject: [PATCH 3/3] this --- app/Jobs/EsDocument.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Jobs/EsDocument.php b/app/Jobs/EsDocument.php index 78a92b45b56..141682d56c9 100644 --- a/app/Jobs/EsDocument.php +++ b/app/Jobs/EsDocument.php @@ -59,7 +59,7 @@ public function handle(): void if ($model !== null) { $model->esIndexDocument(); - static::incrementStat('index'); + $this->incrementStat('index'); return; } @@ -68,7 +68,7 @@ public function handle(): void $keyName = $model->getKeyName(); $model->setAttribute($keyName, $id); $model->esDeleteDocument(); - static::incrementStat('delete'); + $this->incrementStat('delete'); } private function incrementStat(string $action): void