Skip to content

Commit 0e7ac92

Browse files
committed
Add metrics for VC HTTP calls
1 parent 93bcdb6 commit 0e7ac92

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

validator_client/src/attestation_service.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
340340
let attestation_data = self
341341
.beacon_nodes
342342
.first_success(RequireSynced::No, |beacon_node| async move {
343+
let _timer = metrics::start_timer_vec(
344+
&metrics::ATTESTATION_SERVICE_TIMES,
345+
&[metrics::ATTESTATIONS_HTTP_GET],
346+
);
343347
beacon_node
344348
.get_validator_attestation_data(slot, committee_index)
345349
.await
@@ -402,6 +406,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
402406
match self
403407
.beacon_nodes
404408
.first_success(RequireSynced::No, |beacon_node| async move {
409+
let _timer = metrics::start_timer_vec(
410+
&metrics::ATTESTATION_SERVICE_TIMES,
411+
&[metrics::ATTESTATIONS_HTTP_POST],
412+
);
405413
beacon_node
406414
.post_beacon_pool_attestations(attestations_slice)
407415
.await
@@ -454,6 +462,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
454462
let aggregated_attestation = self
455463
.beacon_nodes
456464
.first_success(RequireSynced::No, |beacon_node| async move {
465+
let _timer = metrics::start_timer_vec(
466+
&metrics::ATTESTATION_SERVICE_TIMES,
467+
&[metrics::AGGREGATES_HTTP_GET],
468+
);
457469
beacon_node
458470
.get_validator_aggregate_attestation(
459471
attestation_data_ref.slot,
@@ -506,6 +518,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
506518
match self
507519
.beacon_nodes
508520
.first_success(RequireSynced::No, |beacon_node| async move {
521+
let _timer = metrics::start_timer_vec(
522+
&metrics::ATTESTATION_SERVICE_TIMES,
523+
&[metrics::AGGREGATES_HTTP_POST],
524+
);
509525
beacon_node
510526
.post_validator_aggregate_and_proof(signed_aggregate_and_proofs_slice)
511527
.await

validator_client/src/block_service.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,26 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
263263
let signed_block = self
264264
.beacon_nodes
265265
.first_success(RequireSynced::No, |beacon_node| async move {
266+
let get_timer = metrics::start_timer_vec(
267+
&metrics::BLOCK_SERVICE_TIMES,
268+
&[metrics::BEACON_BLOCK_HTTP_GET],
269+
);
266270
let block = beacon_node
267271
.get_validator_blocks(slot, randao_reveal_ref, graffiti.as_ref())
268272
.await
269273
.map_err(|e| format!("Error from beacon node when producing block: {:?}", e))?
270274
.data;
275+
drop(get_timer);
271276

272277
let signed_block = self_ref
273278
.validator_store
274279
.sign_block(validator_pubkey_ref, block, current_slot)
275280
.ok_or("Unable to sign block")?;
276281

282+
let _post_timer = metrics::start_timer_vec(
283+
&metrics::BLOCK_SERVICE_TIMES,
284+
&[metrics::BEACON_BLOCK_HTTP_POST],
285+
);
277286
beacon_node
278287
.post_beacon_blocks(&signed_block)
279288
.await

validator_client/src/duties_service.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ async fn poll_validator_indices<T: SlotClock + 'static, E: EthSpec>(
285285
let download_result = duties_service
286286
.beacon_nodes
287287
.first_success(duties_service.require_synced, |beacon_node| async move {
288+
let _timer = metrics::start_timer_vec(
289+
&metrics::DUTIES_SERVICE_TIMES,
290+
&[metrics::VALIDATOR_ID_HTTP_GET],
291+
);
288292
beacon_node
289293
.get_beacon_states_validator_id(
290294
StateId::Head,
@@ -453,6 +457,10 @@ async fn poll_beacon_attesters<T: SlotClock + 'static, E: EthSpec>(
453457
if let Err(e) = duties_service
454458
.beacon_nodes
455459
.first_success(duties_service.require_synced, |beacon_node| async move {
460+
let _timer = metrics::start_timer_vec(
461+
&metrics::DUTIES_SERVICE_TIMES,
462+
&[metrics::SUBSCRIPTIONS_HTTP_POST],
463+
);
456464
beacon_node
457465
.post_validator_beacon_committee_subscriptions(subscriptions_ref)
458466
.await
@@ -509,6 +517,10 @@ async fn poll_beacon_attesters_for_epoch<T: SlotClock + 'static, E: EthSpec>(
509517
let response = duties_service
510518
.beacon_nodes
511519
.first_success(duties_service.require_synced, |beacon_node| async move {
520+
let _timer = metrics::start_timer_vec(
521+
&metrics::DUTIES_SERVICE_TIMES,
522+
&[metrics::ATTESTER_DUTIES_HTTP_POST],
523+
);
512524
beacon_node
513525
.post_validator_duties_attester(epoch, local_indices)
514526
.await
@@ -640,6 +652,10 @@ async fn poll_beacon_proposers<T: SlotClock + 'static, E: EthSpec>(
640652
let download_result = duties_service
641653
.beacon_nodes
642654
.first_success(duties_service.require_synced, |beacon_node| async move {
655+
let _timer = metrics::start_timer_vec(
656+
&metrics::DUTIES_SERVICE_TIMES,
657+
&[metrics::PROPOSER_DUTIES_HTTP_GET],
658+
);
643659
beacon_node
644660
.get_validator_duties_proposer(current_epoch)
645661
.await

validator_client/src/http_metrics/metrics.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,25 @@ pub const SAME_DATA: &str = "same_data";
99
pub const UNREGISTERED: &str = "unregistered";
1010
pub const FULL_UPDATE: &str = "full_update";
1111
pub const BEACON_BLOCK: &str = "beacon_block";
12+
pub const BEACON_BLOCK_HTTP_GET: &str = "beacon_block_http_get";
13+
pub const BEACON_BLOCK_HTTP_POST: &str = "beacon_block_http_post";
1214
pub const ATTESTATIONS: &str = "attestations";
15+
pub const ATTESTATIONS_HTTP_GET: &str = "attestations_http_get";
16+
pub const ATTESTATIONS_HTTP_POST: &str = "attestations_http_post";
1317
pub const AGGREGATES: &str = "aggregates";
18+
pub const AGGREGATES_HTTP_GET: &str = "aggregates_http_get";
19+
pub const AGGREGATES_HTTP_POST: &str = "aggregates_http_post";
1420
pub const CURRENT_EPOCH: &str = "current_epoch";
1521
pub const NEXT_EPOCH: &str = "next_epoch";
1622
pub const UPDATE_INDICES: &str = "update_indices";
1723
pub const UPDATE_ATTESTERS_CURRENT_EPOCH: &str = "update_attesters_current_epoch";
1824
pub const UPDATE_ATTESTERS_NEXT_EPOCH: &str = "update_attesters_next_epoch";
1925
pub const UPDATE_ATTESTERS_FETCH: &str = "update_attesters_fetch";
2026
pub const UPDATE_ATTESTERS_STORE: &str = "update_attesters_store";
27+
pub const ATTESTER_DUTIES_HTTP_POST: &str = "attester_duties_http_post";
28+
pub const PROPOSER_DUTIES_HTTP_GET: &str = "proposer_duties_http_get";
29+
pub const VALIDATOR_ID_HTTP_GET: &str = "validator_id_http_get";
30+
pub const SUBSCRIPTIONS_HTTP_POST: &str = "subscriptions_http_post";
2131
pub const UPDATE_PROPOSERS: &str = "update_proposers";
2232
pub const SUBSCRIPTIONS: &str = "subscriptions";
2333

0 commit comments

Comments
 (0)