@@ -2,6 +2,8 @@ package main
2
2
3
3
import (
4
4
"context"
5
+ "encoding/hex"
6
+ "time"
5
7
6
8
"github.com/certusone/wormhole/node/pkg/common"
7
9
"github.com/certusone/wormhole/node/pkg/p2p"
@@ -43,13 +45,26 @@ func ReceiveMessages(channel chan *vaa.VAA, heartbeat *Heartbeat, networkID, boo
43
45
Help : "Count of messages received from the p2p network" ,
44
46
})
45
47
46
- // Ignore observations
48
+ messageLatencyMetric := promauto .NewHistogram (prometheus.HistogramOpts {
49
+ Name : "beacon_message_latency" ,
50
+ Help : "Latency of messages received from the p2p network" ,
51
+ Buckets : []float64 {0.1 , 0.2 , 0.3 , 0.4 , 0.5 , 0.7 , 1 , 1.3 , 1.7 , 2 , 3 , 5 , 10 , 20 },
52
+ })
53
+
54
+ observationsMetric := promauto .NewCounterVec (prometheus.CounterOpts {
55
+ Name : "beacon_observations" ,
56
+ Help : "Count of observations received from the p2p network" ,
57
+ }, []string {"guardian" })
58
+
59
+ // Update metrics for observation to track guardians behaviour
47
60
go func () {
48
61
for {
49
62
select {
50
63
case <- rootCtx .Done ():
51
64
return
52
- case <- obsvC :
65
+ case o := <- obsvC :
66
+ guardian := hex .EncodeToString (o .Msg .Addr )
67
+ observationsMetric .WithLabelValues (guardian ).Inc ()
53
68
}
54
69
}
55
70
}()
@@ -84,6 +99,8 @@ func ReceiveMessages(channel chan *vaa.VAA, heartbeat *Heartbeat, networkID, boo
84
99
// Send message on channel, increment counter, and update heartbeat
85
100
channel <- vaa
86
101
messagesMetric .Inc ()
102
+ messageLatencyMetric .Observe (time .Since (time .Unix (vaa .Timestamp .Unix (), 0 )).Seconds ())
103
+
87
104
if vaa .Timestamp .Unix () > heartbeat .Timestamp {
88
105
heartbeat .Timestamp = vaa .Timestamp .Unix ()
89
106
}
0 commit comments