forked from lix-project/hydra
Merge pull request #1084 from DeterminateSystems/measure-per-event-duration
hydra-notify: track the duration of handling an event
This commit is contained in:
commit
eb5f6c8490
|
@ -4,6 +4,7 @@ use strict;
|
|||
use warnings;
|
||||
use utf8;
|
||||
use Getopt::Long;
|
||||
use Time::HiRes qw( gettimeofday tv_interval );
|
||||
use HTTP::Server::PSGI;
|
||||
use Hydra::Event;
|
||||
use Hydra::Event::BuildFinished;
|
||||
|
@ -46,6 +47,11 @@ $prom->declare(
|
|||
type => "counter",
|
||||
help => "Number of events received that were unprocessable by channel."
|
||||
);
|
||||
$prom->declare(
|
||||
"notify_event_runtime",
|
||||
type => "histogram",
|
||||
help => "Number of seconds spent executing events by channel."
|
||||
);
|
||||
|
||||
my $promCfg = Hydra::Helper::Nix::getHydraNotifyPrometheusConfig($config);
|
||||
if (defined($promCfg)) {
|
||||
|
@ -109,6 +115,7 @@ while (!$queued_only) {
|
|||
$prom->inc("event_loop_iterations");
|
||||
my $messages = $listener->block_for_messages($taskretries->get_seconds_to_next_retry());
|
||||
while (my $message = $messages->()) {
|
||||
my $start_time = [gettimeofday()];
|
||||
$prom->set("event_received", time());
|
||||
my $channelName = $message->{"channel"};
|
||||
my $pid = $message->{"pid"};
|
||||
|
@ -129,7 +136,9 @@ while (!$queued_only) {
|
|||
} or do {
|
||||
$prom->inc("notify_event_error", { channel => $channelName });
|
||||
print STDERR "error processing message '$payload' on channel '$channelName': $@\n";
|
||||
}
|
||||
};
|
||||
|
||||
$prom->histogram_observe("notify_event_runtime", tv_interval($start_time), { channel => $channelName });
|
||||
}
|
||||
|
||||
my $task = $taskretries->get_retryable_task();
|
||||
|
|
Loading…
Reference in a new issue