fix: avoid sending error notifications if the problem is with the InfluxDB server

This commit is contained in:
Maël Gangloff
2024-12-23 15:22:54 +01:00
parent 5f30b7b173
commit efc1cc9a45
2 changed files with 10 additions and 5 deletions

View File

@@ -79,11 +79,15 @@ readonly class InfluxdbService
private function writePoints(Point ...$points): void
{
$writeApi = $this->client->createWriteApi(['writeType' => WriteType::BATCHING, 'batchSize' => count($points)]);
foreach ($points as $point) {
$writeApi->write($point);
}
try {
$writeApi = $this->client->createWriteApi(['writeType' => WriteType::BATCHING, 'batchSize' => count($points)]);
foreach ($points as $point) {
$writeApi->write($point);
}
$writeApi->close();
$writeApi->close();
} catch (\Throwable) {
// TODO: Add a retry mechanism if writing fails
}
}
}

View File

@@ -19,6 +19,7 @@ readonly class StatService
return $this->pool->save($item);
} catch (\Throwable) {
// TODO: Add a retry mechanism if writing fails
}
return false;