From 896edfe072d3aa1654e05285d12f35fccab0e91f Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 20 Aug 2020 23:14:32 +0300 Subject: [PATCH] pubsub metrics for RPCs --- metrics/metrics.go | 3 +++ node/modules/lp2p/pubsub.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/metrics/metrics.go b/metrics/metrics.go index f81af5845..e00208d5d 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -44,6 +44,9 @@ var ( PubsubDeliverMessage = stats.Int64("pubsub/delivered", "Counter for total delivered messages", stats.UnitDimensionless) PubsubRejectMessage = stats.Int64("pubsub/rejected", "Counter for total rejected messages", stats.UnitDimensionless) PubsubDuplicateMessage = stats.Int64("pubsub/duplicate", "Counter for total duplicate messages", stats.UnitDimensionless) + PubsubRecvRPC = stats.Int64("pubsub/recv_rpc", "Counter for total received RPCs", stats.UnitDimensionless) + PubsubSendRPC = stats.Int64("pubsub/send_rpc", "Counter for total sent RPCs", stats.UnitDimensionless) + PubsubDropRPC = stats.Int64("pubsub/drop_rpc", "Counter for total dropped RPCs", stats.UnitDimensionless) ) var ( diff --git a/node/modules/lp2p/pubsub.go b/node/modules/lp2p/pubsub.go index 41f6599a8..86d94e45a 100644 --- a/node/modules/lp2p/pubsub.go +++ b/node/modules/lp2p/pubsub.go @@ -374,5 +374,11 @@ func (trw *tracerWrapper) Trace(evt *pubsub_pb.TraceEvent) { if trw.tr != nil { trw.tr.Trace(evt) } + case pubsub_pb.TraceEvent_RECV_RPC: + stats.Record(context.TODO(), metrics.PubsubRecvRPC.M(1)) + case pubsub_pb.TraceEvent_SEND_RPC: + stats.Record(context.TODO(), metrics.PubsubSendRPC.M(1)) + case pubsub_pb.TraceEvent_DROP_RPC: + stats.Record(context.TODO(), metrics.PubsubDropRPC.M(1)) } }