@@ -167,20 +167,38 @@ func (buf *SequentialBufferChanImpl) Reset() [][]byte {
167
167
return ret
168
168
}
169
169
170
+ type MetricsGroup struct {
171
+ Events metrics.Counter
172
+ Errors metrics.Counter
173
+ QueueLength metrics.Gauge
174
+ }
175
+
170
176
type StreamingMetrics struct {
171
177
Reg metrics.Registry
172
- Total metrics.Counter // total count of packets.
173
- Current metrics.Counter // packets in the last period
174
- Error metrics.Counter // total count of packets that are dropped
175
- StartTime int64 // How long we've been running for
178
+ OpGroups map [string ]MetricsGroup // Each Op can have an associated metrics group
179
+ StartTime int64 // How long we've been running for
180
+ }
181
+
182
+ func (m * StreamingMetrics ) Event (op * string ) {
183
+ m .OpGroups [* op ].Events .Inc (1 )
184
+ }
185
+
186
+ func (m * StreamingMetrics ) Error (op * string ) {
187
+ m .OpGroups [* op ].Errors .Inc (1 )
188
+ }
189
+
190
+ func (m * StreamingMetrics ) Update (op * string , v int ) {
191
+ m .OpGroups [* op ].QueueLength .Update (int64 (v ))
192
+ }
193
+
194
+ func (m * StreamingMetrics ) Register (op string ) {
195
+ m .OpGroups [op ] = MetricsGroup {metrics .NewCounter (), metrics .NewCounter (), metrics .NewGauge ()}
176
196
}
177
197
178
198
func NewStreamingMetrics (mReg metrics.Registry ) * StreamingMetrics {
179
199
return & StreamingMetrics {
180
200
Reg : mReg ,
181
- Total : metrics .NewCounter (),
182
- Current : metrics .NewCounter (),
183
- Error : metrics .NewCounter (),
201
+ OpGroups : make (map [string ]MetricsGroup ),
184
202
StartTime : time .Now ().Unix (),
185
203
}
186
204
}
0 commit comments