Skip to content

Commit e20856f

Browse files
committed
Update metrics
1 parent 2fa1b1b commit e20856f

7 files changed

Lines changed: 360 additions & 38 deletions

File tree

metrics/multinode.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ var (
6767
Help: "Total number of times node has transitioned to Syncing",
6868
}, []string{"network", "chainID", "nodeName"})
6969

70-
// Node Lifecycle TODO START - ADD THESE ONES:
70+
// Node Lifecycle
7171
promPoolRPCNodeHighestSeenBlock = promauto.NewGaugeVec(prometheus.GaugeOpts{
7272
Name: "pool_rpc_node_highest_seen_block",
7373
Help: "The highest seen block for the given RPC node",
7474
}, []string{"network", "chainID", "nodeName"})
75-
promPoolRPCNodeHighestFinalizedBlock = promauto.NewGaugeVec(prometheus.GaugeOpts{
75+
PromPoolRPCNodeHighestFinalizedBlock = promauto.NewGaugeVec(prometheus.GaugeOpts{
7676
Name: "pool_rpc_node_highest_finalized_block",
7777
Help: "The highest seen finalized block for the given RPC node",
7878
}, []string{"network", "chainID", "nodeName"})
@@ -92,7 +92,6 @@ var (
9292
Name: "pool_rpc_node_polls_success",
9393
Help: "The total number of successful poll checks for the given RPC node",
9494
}, []string{"network", "chainID", "nodeName"})
95-
// TODO: END
9695

9796
// Transaction Sender
9897
promMultiNodeInvariantViolations = promauto.NewCounterVec(prometheus.CounterOpts{

metrics/multinode_test.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,66 @@ func TestMultiNodeMetrics_NodeTransitions(t *testing.T) {
143143
}
144144
}
145145

146+
func TestMultiNodeMetrics_LifecycleMetrics(t *testing.T) {
147+
m := setupTestMultiNodeMetrics(t)
148+
ctx := context.Background()
149+
nodeName := "node-1"
150+
151+
t.Run("SetHighestSeenBlock", func(t *testing.T) {
152+
m.SetHighestSeenBlock(ctx, nodeName, 123)
153+
require.InEpsilon(t,
154+
123.0,
155+
testutil.ToFloat64(promPoolRPCNodeHighestSeenBlock.WithLabelValues("test-network", "1", nodeName)),
156+
0.001,
157+
)
158+
})
159+
160+
t.Run("SetHighestFinalizedBlock", func(t *testing.T) {
161+
m.SetHighestFinalizedBlock(ctx, nodeName, 456)
162+
require.InEpsilon(t,
163+
456.0,
164+
testutil.ToFloat64(promPoolRPCNodeHighestFinalizedBlock.WithLabelValues("test-network", "1", nodeName)),
165+
0.001,
166+
)
167+
})
168+
169+
t.Run("IncrementSeenBlocks", func(t *testing.T) {
170+
m.IncrementSeenBlocks(ctx, nodeName)
171+
require.InEpsilon(t,
172+
1.0,
173+
testutil.ToFloat64(promPoolRPCNodeNumSeenBlocks.WithLabelValues("test-network", "1", nodeName)),
174+
0.001,
175+
)
176+
})
177+
178+
t.Run("IncrementPolls", func(t *testing.T) {
179+
m.IncrementPolls(ctx, nodeName)
180+
require.InEpsilon(t,
181+
1.0,
182+
testutil.ToFloat64(promPoolRPCNodePolls.WithLabelValues("test-network", "1", nodeName)),
183+
0.001,
184+
)
185+
})
186+
187+
t.Run("IncrementPollsFailed", func(t *testing.T) {
188+
m.IncrementPollsFailed(ctx, nodeName)
189+
require.InEpsilon(t,
190+
1.0,
191+
testutil.ToFloat64(promPoolRPCNodePollsFailed.WithLabelValues("test-network", "1", nodeName)),
192+
0.001,
193+
)
194+
})
195+
196+
t.Run("IncrementPollsSuccess", func(t *testing.T) {
197+
m.IncrementPollsSuccess(ctx, nodeName)
198+
require.InEpsilon(t,
199+
1.0,
200+
testutil.ToFloat64(promPoolRPCNodePollsSuccess.WithLabelValues("test-network", "1", nodeName)),
201+
0.001,
202+
)
203+
})
204+
}
205+
146206
func TestMultiNodeMetrics_IncrementInvariantViolations(t *testing.T) {
147207
m := setupTestMultiNodeMetrics(t)
148208
ctx := context.Background()

multinode/mock_node_metrics_test.go

Lines changed: 241 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)