Permalink
Browse files

improve Sonar to handle edge case times and not increment process cou…

…nter
  • Loading branch information...
laurencei committed Jun 11, 2018
1 parent dc10cd3 commit 1623d55b9cb364d472458f259004d7f457d0e3cc
@@ -32,7 +32,7 @@ public function process($connectionName, $job, WorkerOptions $options)
} catch (Throwable $e) {
$this->recordJobException($e);
} finally {
$this->recordJobEnd($startTime);
$this->recordJobEnd($startTime, $job->resolveName());
}
}
}
@@ -34,7 +34,7 @@ public function process($connection, Job $job, $maxTries = 0, $delay = 0)
} catch (Throwable $e) {
$this->recordJobException($e);
} finally {
$this->recordJobEnd($startTime);
$this->recordJobEnd($startTime, $job->resolveName());
return $result;
}
}
@@ -65,19 +65,24 @@ protected function eyewitnessHeartbeat($queue)
}
/**
* Record the end of the job details.
* Record the end of the job details. Ignore the sonar job from artifically inflating
* the queue counters.
*
* @param float $startTime
* @param string $jobName
* @return void
*/
public function recordJobEnd($startTime)
public function recordJobEnd($startTime, $jobName)
{
$endTime = round((microtime(true) - $startTime)*1000);
$this->cache->add('eyewitness_q_process_time_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_time_'.$this->currentQueue->id, $endTime);
$this->cache->add('eyewitness_q_process_count_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_count_'.$this->currentQueue->id);
if ($jobName !== "Eyewitness\\Eye\\Queue\\Jobs\\Sonar") {
$this->cache->add('eyewitness_q_process_count_'.$this->currentQueue->id, 0, 180);
$this->cache->increment('eyewitness_q_process_count_'.$this->currentQueue->id);
}
}
/**
@@ -16,7 +16,7 @@ public function up()
Schema::connection(config('eyewitness.eyewitness_database_connection'))->create('eyewitness_io_history_scheduler', function (Blueprint $table) {
$table->bigIncrements('id');
$table->integer('scheduler_id')->unsigned()->index();
$table->decimal('time_to_run', 9, 4)->nullable()->default(null);
$table->decimal('time_to_run', 10, 4)->nullable()->default(null);
$table->integer('exitcode')->index()->nullable()->default(null);
$table->text('output')->nullable()->default(null);
$table->boolean('overdue')->default(false);
@@ -18,7 +18,7 @@ public function up()
$table->string('connection', 191);
$table->string('tube', 191);
$table->string('driver', 191);
$table->decimal('current_wait_time')->default(0);
$table->decimal('current_wait_time', 10, 2)->default(0);
$table->boolean('healthy')->nullable()->default(null)->index();
$table->boolean('alert_on_failed_job')->default(true);
$table->integer('alert_heartbeat_greater_than')->default(120);
@@ -19,9 +19,9 @@ public function up()
$table->integer('pending_count')->unsigned()->default(0);
$table->integer('failed_count')->unsigned()->default(0);
$table->integer('exception_count')->unsigned()->default(0);
$table->decimal('sonar_time', 8,2)->unsigned()->default(0);
$table->decimal('sonar_time', 10,2)->unsigned()->default(0);
$table->integer('sonar_count')->unsigned()->default(0);
$table->decimal('process_time', 8,2)->unsigned()->default(0);
$table->decimal('process_time', 10,2)->unsigned()->default(0);
$table->integer('process_count')->unsigned()->default(0);
$table->integer('idle_time')->unsigned()->default(0);
$table->integer('sonar_deployed')->nullable()->default(null);

0 comments on commit 1623d55

Please sign in to comment.