From 6fd05537617324c8b64a9d2389b988d3412228cb Mon Sep 17 00:00:00 2001 From: Mike Garde Date: Thu, 22 Aug 2019 16:19:23 -0400 Subject: [PATCH] Allowing for Flushing --- src/DataDogHelper.php | 4 ---- src/DoctrineFileLogger.php | 8 +++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/DataDogHelper.php b/src/DataDogHelper.php index 6e52abe..c0a3f95 100644 --- a/src/DataDogHelper.php +++ b/src/DataDogHelper.php @@ -177,8 +177,6 @@ public function set($stat, $value, $sampleRate = 1.0, $tags = null) * @param float $sampleRate the rate (0-1) for sampling. * @param array|string $tags Key Value array of Tag => Value, or single tag as string * @param int $value the amount to increment by (default 1) - * - * @return boolean **/ public function increment($stats, $sampleRate = 1.0, $tags = null, $value = 1) { @@ -192,8 +190,6 @@ public function increment($stats, $sampleRate = 1.0, $tags = null, $value = 1) * @param float $sampleRate the rate (0-1) for sampling. * @param array|string $tags Key Value array of Tag => Value, or single tag as string * @param int $value the amount to decrement by (default -1) - * - * @return boolean **/ public function decrement($stats, $sampleRate = 1.0, $tags = null, $value = -1) { diff --git a/src/DoctrineFileLogger.php b/src/DoctrineFileLogger.php index ea6e3ac..47464fc 100644 --- a/src/DoctrineFileLogger.php +++ b/src/DoctrineFileLogger.php @@ -65,7 +65,7 @@ public function startQuery($sql, array $params = null, array $types = null) public function stopQuery() { $tmp = app('router')->getCurrentRoute(); - $tmp = method_exists($tmp, 'uri') ? $tmp->uri() : 'composerInstall'; + $tmp = method_exists($tmp, 'uri') ? $tmp->uri() : 'unknown'; $route = ($tmp) ?: ''; $tag = [ @@ -75,6 +75,12 @@ public function stopQuery() ]; DataDog::increment('sql', 1, $tag); DataDog::microtiming('sql.timing', $this->getExecutionTime(), 1, $tag); + + // Some users may enable DataDog on Workers, if so lets periodically flush the buffer to DataDog + if (rand(1,100) === 1) + { + DataDog::flush(); + } } /**