fix: unable to sense the quit of hrp in Prometheus

This commit is contained in:
xucong053
2022-03-16 18:32:13 +08:00
parent 3e014cee12
commit f1c7994082

View File

@@ -119,15 +119,15 @@ func (o *ConsoleOutput) OnEvent(data map[string]interface{}) {
var state string var state string
switch output.State { switch output.State {
case 1: case stateInit:
state = "initializing" state = "initializing"
case 2: case stateSpawning:
state = "spawning" state = "spawning"
case 3: case stateRunning:
state = "running" state = "running"
case 4: case stateQuitting:
state = "quitting" state = "quitting"
case 5: case stateStopped:
state = "stopped" state = "stopped"
} }
@@ -463,7 +463,11 @@ func (o *PrometheusPusherOutput) OnStart() {
// OnStop of PrometheusPusherOutput has nothing to do. // OnStop of PrometheusPusherOutput has nothing to do.
func (o *PrometheusPusherOutput) OnStop() { func (o *PrometheusPusherOutput) OnStop() {
// update runner state: stopped
gaugeState.Set(float64(stateStopped))
if err := o.pusher.Push(); err != nil {
log.Error().Err(err).Msg("push to Pushgateway failed")
}
} }
// OnEvent will push metric to Prometheus Pushgataway // OnEvent will push metric to Prometheus Pushgataway