forked from lix-project/hydra
hydra-notify: support sending diagnostic dumps to STDERR on request
This commit is contained in:
parent
de2282bcf4
commit
45e8fa5319
|
@ -21,3 +21,13 @@ for details on enabling and configuring the exporter.
|
|||
|
||||
The notification exporter exposes metrics on a per-plugin, per-event-type basis: execution
|
||||
durations, frequency, successes, and failures.
|
||||
|
||||
### Diagnostic Dump
|
||||
|
||||
The notification daemon can also dump its metrics to stderr whether or not the exporter
|
||||
is configured. This is particularly useful for cases where metrics data is needed but the
|
||||
exporter was not enabled.
|
||||
|
||||
To trigger this diagnostic dump, send a Postgres notification with the
|
||||
`hydra_notify_dump_metrics` channel and no payload. See
|
||||
[Re-sending a notification](../notifications.md#re-sending-a-notification).
|
||||
|
|
|
@ -99,6 +99,7 @@ my $listener = Hydra::PostgresListener->new($dbh);
|
|||
$listener->subscribe("build_started");
|
||||
$listener->subscribe("build_finished");
|
||||
$listener->subscribe("step_finished");
|
||||
$listener->subscribe("hydra_notify_dump_metrics");
|
||||
|
||||
sub runPluginsForEvent {
|
||||
my ($event) = @_;
|
||||
|
@ -145,6 +146,11 @@ while (!$queued_only) {
|
|||
|
||||
$prom->inc("notify_event", { channel => $channelName });
|
||||
|
||||
if ($channelName eq "hydra_notify_dump_metrics") {
|
||||
print STDERR "Dumping prometheus metrics:\n${\$prom->format}\n";
|
||||
next;
|
||||
}
|
||||
|
||||
eval {
|
||||
my $event = Hydra::Event->new_event($channelName, $message->{"payload"});
|
||||
runPluginsForEvent($event);
|
||||
|
|
Loading…
Reference in a new issue