File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,7 @@ func (r *ValidatorRegistry) GetCombinedValidator(topic string) pubsub.ValidatorE
34
34
startTime := time .Now ()
35
35
defer func () {
36
36
elapsedTime := time .Since (startTime )
37
- log .Debug ().
38
- Str ("topic" , topic ).
39
- Str ("duration" , elapsedTime .String ()).
40
- Msg ("validated message" )
37
+ metricsP2PMessageValidationTime .WithLabelValues (topic ).Observe (elapsedTime .Seconds ())
41
38
}()
42
39
43
40
ignored := false
@@ -275,13 +272,16 @@ func (m *P2PMessaging) runHandleMessages(ctx context.Context) error {
275
272
if ! ok {
276
273
return nil
277
274
}
275
+ startTime := time .Now ()
278
276
if err := m .handle (ctx , msg ); err != nil {
279
277
log .Info ().
280
278
Err (err ).
281
279
Str ("topic" , msg .GetTopic ()).
282
280
Str ("sender-id" , msg .GetFrom ().String ()).
283
281
Msg ("failed to handle message" )
284
282
}
283
+ elapsedTime := time .Since (startTime )
284
+ metricsP2PMessageHandlingTime .WithLabelValues (msg .GetTopic ()).Observe (elapsedTime .Seconds ())
285
285
case <- ctx .Done ():
286
286
return ctx .Err ()
287
287
}
Original file line number Diff line number Diff line change
1
+ package p2p
2
+
3
+ import "github.com/prometheus/client_golang/prometheus"
4
+
5
+ var metricsP2PMessageValidationTime = prometheus .NewHistogramVec (
6
+ prometheus.HistogramOpts {
7
+ Namespace : "shutter" ,
8
+ Subsystem : "p2p" ,
9
+ Name : "message_validation_time_seconds" ,
10
+ Help : "Histogram of the time it takes to validate a P2P message." ,
11
+ Buckets : prometheus .DefBuckets ,
12
+ },
13
+ []string {"topic" },
14
+ )
15
+
16
+ var metricsP2PMessageHandlingTime = prometheus .NewHistogramVec (
17
+ prometheus.HistogramOpts {
18
+ Namespace : "shutter" ,
19
+ Subsystem : "p2p" ,
20
+ Name : "message_handling_time_seconds" ,
21
+ Help : "Histogram of the time it takes to handle a P2P message." ,
22
+ Buckets : prometheus .DefBuckets ,
23
+ },
24
+ []string {"topic" },
25
+ )
26
+
27
+ func init () {
28
+ prometheus .MustRegister (metricsP2PMessageValidationTime )
29
+ prometheus .MustRegister (metricsP2PMessageHandlingTime )
30
+ }
You can’t perform that action at this time.
0 commit comments