Skip to content

Commit

Permalink
add metrics for showtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulexus committed Aug 19, 2022
1 parent f42cc72 commit e6a12c1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions showtime/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"github.com/labstack/echo/v4"
"github.com/prometheus/client_golang/prometheus"
)

const (
Expand All @@ -24,6 +25,29 @@ const maxUDPMessageSize = 512

var minUpdateInterval = time.Duration(2) * time.Second

var (
metricCueCount prometheus.Counter
metricCueQLabCount prometheus.Counter
metricSubsCount prometheus.Gauge
)

func init() {
metricCueQLabCount = prometheus.NewCounter(prometheus.CounterOpts{
Name: "audimance_cue_qlab_total",
Help: "Total number of cues received from QLab",
})

metricCueCount = prometheus.NewCounter(prometheus.CounterOpts{
Name: "audimance_cue_total",
Help: "Total number of cues processed",
})

metricSubsCount = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "audimance_subs_count",
Help: "Current number of active subscriptions",
})
}

// Time describes the time at which the last Cue occurred
type Time struct {

Expand Down Expand Up @@ -149,6 +173,8 @@ func (s *Service) notify(cause string) {
TimePoints: points,
}

metricSubsCount.Set(float64(len(s.subs)))

for _, sub := range s.subs {
select {
case sub.C <- ann:
Expand All @@ -172,6 +198,8 @@ func (s *Service) processUDP(conn *net.UDPConn) {

// Update the showtime Time
s.Trigger(recv)

metricCueQLabCount.Add(1)
}
}

Expand All @@ -186,6 +214,8 @@ func (s *Service) Trigger(cue string) {

s.Echo.Logger.Info("triggering cue:", cue)
s.notify(CueNotification)

metricCueCount.Add(1)
}

// Subscription represents a subscription to showtime announcements
Expand Down

0 comments on commit e6a12c1

Please sign in to comment.