Skip to content

Commit

Permalink
Added metric to monitor events channel buffer lenght
Browse files Browse the repository at this point in the history
  • Loading branch information
helder-junior committed Nov 5, 2024
1 parent 43cc881 commit 732f2f3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ func (a *gRPCClientAsync) sendRoutine() {
for {
select {
case e := <-a.eventsChannel:
metrics.AsyncClientEventsChannelLength.WithLabelValues(
e.Topic).Set(float64(len(a.eventsChannel)))
if len(req.Events) == 0 {
a.wg.Add(1)
}
Expand Down
11 changes: 11 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ var (
[]string{LabelRoute, LabelTopic, LabelStatus},
)

// AsyncClientEventsChannelLength is the number of current events in the eventsChannel buffer
AsyncClientEventsChannelLength = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: metricsNamespace,
Subsystem: metricsSubsystem,
Name: "async_events_channel_length",
Help: "the number of current events in the eventsChannel buffer in the async client",
},
[]string{LabelTopic},
)

// AsyncClientEventsDroppedCounter is the count of requests that were dropped due
// to req.Retry > maxRetries. Only available for Async mode
AsyncClientEventsDroppedCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
Expand All @@ -88,6 +98,7 @@ func RegisterMetrics(configPrefix string, config *viper.Viper) error {
ClientRequestsResponseTime,
ClientEventsCounter,
AsyncClientEventsDroppedCounter,
AsyncClientEventsChannelLength,
}

for _, collector := range collectors {
Expand Down

0 comments on commit 732f2f3

Please sign in to comment.