File tree Expand file tree Collapse file tree 4 files changed +8
-1
lines changed
Expand file tree Collapse file tree 4 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -9,13 +9,15 @@ import (
99
1010const namespace = "goengine"
1111
12+ // Metrics is an object for exposing prometheus metrics
1213type Metrics struct {
1314 notificationCounter * prometheus.CounterVec
1415 notificationQueueDuration * prometheus.HistogramVec
1516 notificationProcessingDuration * prometheus.HistogramVec
1617 notificationStartTimes map [string ]time.Time
1718}
1819
20+ // NewMetrics instantiate and return an object of Metrics
1921func NewMetrics () * Metrics {
2022 return & Metrics {
2123 // notificationCounter is used to expose 'notification_count' metric
@@ -66,7 +68,7 @@ func (m *Metrics) RegisterMetrics(registry *prometheus.Registry) error {
6668 return registry .Register (m .notificationProcessingDuration )
6769}
6870
69- // ReceivedNotification
71+ // ReceivedNotification counts received notifications
7072func (m * Metrics ) ReceivedNotification (isNotification bool ) {
7173 labels := prometheus.Labels {"is_notification" : strconv .FormatBool (isNotification )}
7274 m .notificationCounter .With (labels ).Inc ()
Original file line number Diff line number Diff line change 11package goengine
22
3+ // NopMetrics is default Metrics handler in case nil is passed
34var NopMetrics Metrics = & nopMetrics {}
45
56type nopMetrics struct {}
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ func (s *aggregateProjectorTestSuite) TestRunAndListen() {
9393 time .Millisecond ,
9494 time .Second ,
9595 s .GetLogger (),
96+ s .Metrics ,
9697 )
9798 s .Require ().NoError (err )
9899
@@ -109,6 +110,7 @@ func (s *aggregateProjectorTestSuite) TestRunAndListen() {
109110 return driverSQL .ProjectionFail
110111 },
111112 s .GetLogger (),
113+ s .Metrics ,
112114 )
113115 s .Require ().NoError (err , "failed to create projector" )
114116
@@ -206,6 +208,7 @@ func (s *aggregateProjectorTestSuite) TestRunAndListen() {
206208 return driverSQL .ProjectionFail
207209 },
208210 s .GetLogger (),
211+ s .Metrics ,
209212 )
210213 s .Require ().NoError (err , "failed to create projector" )
211214
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ func (s *streamProjectorTestSuite) TestRunAndListen() {
102102 time .Millisecond ,
103103 time .Second ,
104104 s .GetLogger (),
105+ s .Metrics ,
105106 )
106107 s .Require ().NoError (err )
107108
You can’t perform that action at this time.
0 commit comments