Skip to content

Commit

Permalink
add method to reset sender metrics (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
karenychen authored Jul 17, 2024
1 parent 9604713 commit f3bc6b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions v2/metrics/sender/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Recorder interface {
Init(registerer prom.Registerer)
IncSendMessageSuccessCount()
IncSendMessageFailureCount()
ResetSendMessageCount()
IncHealthCheckSuccessCount(namespace, entity string)
IncHealthCheckFailureCount(namespace, entity string)
}
Expand All @@ -71,6 +72,10 @@ func (m *Registry) IncSendMessageFailureCount() {
}).Inc()
}

func (m *Registry) ResetSendMessageCount() {
m.MessageSentCount.Reset()
}

// IncHealthCheckSuccessCount increases the connection success gauge and resets the failure gauge
func (m *Registry) IncHealthCheckSuccessCount(namespace, entity string) {
m.HealthCheckCount.With(
Expand Down
6 changes: 6 additions & 0 deletions v2/metrics/sender/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ func TestSendMetrics(t *testing.T) {
count, err = informer.GetSendMessageFailureCount()
g.Expect(err).ToNot(HaveOccurred())
g.Expect(count).To(Equal(float64(1)))

// count resets properly
r.ResetSendMessageCount()
count, err = informer.GetSendMessageFailureCount()
g.Expect(err).ToNot(HaveOccurred())
g.Expect(count).To(Equal(float64(0)))
}

func TestConnectionMetrics(t *testing.T) {
Expand Down

0 comments on commit f3bc6b3

Please sign in to comment.