Skip to content

Commit

Permalink
Send metric about cache size on each poll
Browse files Browse the repository at this point in the history
  • Loading branch information
dkeysil committed Mar 27, 2024
1 parent a3e3849 commit 214d3b3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion services/json-rpc/cache/json_rpc_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ func (c *JsonRpcCache) pollBlocksData() {
// wait for the next bucket
<-time.After(time.Duration(bucket-time.Now().Unix()) * time.Second)

c.msgClient.PublishProto(
messaging.SubjectMetricAgent, &protocol.AgentMetricList{
Metrics: []*protocol.AgentMetric{
metrics.CreateSystemMetric(domain.MetricJSONRPCCacheSize, float64(c.cache.cache.ItemCount()), ""),
},
},
)

agents, err := c.botRegistry.LoadAssignedBots()
if err == nil && len(agents) == 0 {
log.Warn("No agents assigned to the scanner, skipping polling for BlocksData")
Expand All @@ -218,7 +226,6 @@ func (c *JsonRpcCache) pollBlocksData() {
messaging.SubjectMetricAgent, &protocol.AgentMetricList{
Metrics: []*protocol.AgentMetric{
metrics.CreateSystemMetric(domain.MetricJSONRPCCachePollSuccess, float64(len(blocksData.Blocks)), fmt.Sprintf("%d", b)),
metrics.CreateSystemMetric(domain.MetricJSONRPCCacheSize, float64(c.cache.cache.ItemCount()), ""),
},
},
)
Expand Down

0 comments on commit 214d3b3

Please sign in to comment.