Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ddev-1966' into ddev-1966
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Davydenko committed Dec 6, 2024
2 parents 37bca0e + dcc422a commit 584bf3b
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/Command/CommandMetrics.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public static function write(CommandFinished $event): void

$labels = CommandLabels::extractFromTask($event);

app()->terminating(fn() => Prometheus::update('command_runs_total', 1, $labels));
app()->terminating(fn() => Prometheus::update('command_run_seconds_total', Helper::duration(), $labels));
app()->terminating(fn () => Prometheus::update('command_runs_total', 1, $labels));
app()->terminating(fn () => Prometheus::update('command_run_seconds_total', Helper::duration(), $labels));
}

protected static function needToIgnoreCommand(?string $command): bool
Expand Down
4 changes: 2 additions & 2 deletions src/Guzzle/GuzzleMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public static function handleResponse(string $type, $start, string $host): void

$labels = [$host];

app()->terminating(fn() => Prometheus::update('http_client_seconds_total', $end - $start, $labels));
app()->terminating(fn () => Prometheus::update('http_client_seconds_total', $end - $start, $labels));

app()->terminating(fn() => Prometheus::update('http_client_requests_total', 1, $labels));
app()->terminating(fn () => Prometheus::update('http_client_requests_total', 1, $labels));
}
}
4 changes: 2 additions & 2 deletions src/Job/JobMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function handle($job, $next)
$next($job);
$duration = microtime(true) - $start;

app()->terminating(fn() => Prometheus::update('queue_job_runs_total', 1, $labels));
app()->terminating(fn() => Prometheus::update('queue_job_run_seconds_total', $duration, $labels));
app()->terminating(fn () => Prometheus::update('queue_job_runs_total', 1, $labels));
app()->terminating(fn () => Prometheus::update('queue_job_run_seconds_total', $duration, $labels));
}
}
4 changes: 2 additions & 2 deletions src/Kafka/KafkaMetricsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private function writeMetrics(Message $message, float $startKafka, KafkaResponse
$duration = microtime(true) - $startKafka;
$labels = KafkaLabels::extractFromMessage($message, $status->value);

app()->terminating(fn() => Prometheus::update('kafka_runs_total', 1, $labels));
app()->terminating(fn() => Prometheus::update('kafka_run_seconds_total', $duration, $labels));
app()->terminating(fn () => Prometheus::update('kafka_runs_total', 1, $labels));
app()->terminating(fn () => Prometheus::update('kafka_run_seconds_total', $duration, $labels));
}
}
10 changes: 5 additions & 5 deletions src/MetricsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,24 @@ private function registerEventListeners(): void
});

Event::listen(MessageLogged::class, function (MessageLogged $event) {
app()->terminating(fn() => Prometheus::update('log_messages_count', 1, [$event->level]));
app()->terminating(fn () => Prometheus::update('log_messages_count', 1, [$event->level]));
});

Event::listen(JobFailed::class, function (JobFailed $event) {
app()->terminating(fn() => Prometheus::update('queue_job_failed_total', 1, JobLabels::extractFromJob($event->job)));
app()->terminating(fn () => Prometheus::update('queue_job_failed_total', 1, JobLabels::extractFromJob($event->job)));
});

Event::listen(JobQueued::class, function (JobQueued $event) {
app()->terminating(fn() => Prometheus::update('queue_job_dispatched_total', 1, JobLabels::extractFromJob($event->job)));
app()->terminating(fn () => Prometheus::update('queue_job_dispatched_total', 1, JobLabels::extractFromJob($event->job)));
});

Bus::pipeThrough([
JobMiddleware::class,
]);

Event::listen(ScheduledTaskFinished::class, function (ScheduledTaskFinished $event) {
app()->terminating(fn() => Prometheus::update('task_runs_total', 1, TaskLabels::extractFromTask($event->task)));
app()->terminating(fn() => Prometheus::update('task_run_seconds_total', $event->runtime, TaskLabels::extractFromTask($event->task)));
app()->terminating(fn () => Prometheus::update('task_runs_total', 1, TaskLabels::extractFromTask($event->task)));
app()->terminating(fn () => Prometheus::update('task_run_seconds_total', $event->runtime, TaskLabels::extractFromTask($event->task)));
});

Event::listen(CommandFinished::class, function (CommandFinished $event) {
Expand Down
4 changes: 2 additions & 2 deletions src/Workers/WorkerUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public function register(MetricsBag $metricsBag): void
public function update(MetricsBag $metricsBag): void
{
if ($this->hasSwoole()) {
app()->terminating(fn() => Prometheus::update('workers_total', $this->getTotal()));
app()->terminating(fn() => Prometheus::update('workers_idle', $this->getIdle()));
app()->terminating(fn () => Prometheus::update('workers_total', $this->getTotal()));
app()->terminating(fn () => Prometheus::update('workers_idle', $this->getIdle()));
}
}

Expand Down

0 comments on commit 584bf3b

Please sign in to comment.