Skip to content

Commit

Permalink
add time-since-last-cue metric
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Sep 9, 2022
1 parent 1d61eba commit 65796b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions showtime/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var (
metricCueCount prometheus.Counter
metricCueQLabCount prometheus.Counter
metricSubsCount prometheus.Gauge
metricTimeSinceLastCue prometheus.Gauge
)

func init() {
Expand All @@ -47,6 +48,11 @@ func init() {
Name: "audimance_subs_count",
Help: "Current number of active subscriptions",
})

metricTimeSinceLastCue = promauto.NewGauge(prometheus.GaugeOpts{
Name: "audimance_time_since_last_cue_s",
Help: "Number of seconds since the last-received cue",
})
}

// Time describes the time at which the last Cue occurred
Expand Down Expand Up @@ -169,6 +175,10 @@ func (s *Service) notify(cause string) {
points = append(points, t.Now())
}

if len(s.Times) > 0 {
metricTimeSinceLastCue.Set(s.Times[len(s.Times)-1].OffsetSeconds())
}

ann := &Announcement{
Cause: cause,
TimePoints: points,
Expand Down

0 comments on commit 65796b0

Please sign in to comment.