Skip to content

Commit

Permalink
Merge pull request #532 from netixx/feat/failed-subscribe-metrics
Browse files Browse the repository at this point in the history
Add a metric for failed subscriptions
  • Loading branch information
karimra authored Nov 4, 2024
2 parents 460306a + 66c77f2 commit cc35c12
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/app/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (a *App) newAPIServer() (*http.Server, error) {
a.reg.MustRegister(collectors.NewGoCollector())
a.reg.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
a.reg.MustRegister(subscribeResponseReceivedCounter)
a.reg.MustRegister(subscribeResponseFailedCounter)
go a.startClusterMetrics()
}
s := &http.Server{
Expand Down
3 changes: 2 additions & 1 deletion pkg/app/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func (a *App) StartCollector(ctx context.Context) {
case tErr := <-errChan:
if errors.Is(tErr.Err, io.EOF) {
a.Logger.Printf("target %q: subscription %s closed stream(EOF)", t.Config.Name, tErr.SubscriptionName)
} else {
} else {
subscribeResponseFailedCounter.WithLabelValues(t.Config.Name, tErr.SubscriptionName).Inc()
a.Logger.Printf("target %q: subscription %s rcv error: %v", t.Config.Name, tErr.SubscriptionName, tErr.Err)
}
if remainingOnceSubscriptions > 0 {
Expand Down
7 changes: 7 additions & 0 deletions pkg/app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ var subscribeResponseReceivedCounter = prometheus.NewCounterVec(prometheus.Count
Help: "Total number of received subscribe response messages",
}, []string{"source", "subscription"})

var subscribeResponseFailedCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "gnmic",
Subsystem: "subscribe",
Name: "number_of_failed_subscribe_request_messages_total",
Help: "Total number of failed subscribe requests",
}, []string{"source", "subscription"})

// cluster
var clusterNumberOfLockedTargets = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "gnmic",
Expand Down

0 comments on commit cc35c12

Please sign in to comment.