Skip to content

Commit

Permalink
Observability - beacon client 'Validators' endpoint request duration …
Browse files Browse the repository at this point in the history
…metric
  • Loading branch information
oleg-ssvlabs committed Jan 16, 2025
1 parent 67b6d43 commit c57d7f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions beacon/goclient/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package goclient

import (
"fmt"
"net/http"
"time"

"github.com/attestantio/go-eth2-client/api"
eth2apiv1 "github.com/attestantio/go-eth2-client/api/v1"
Expand All @@ -11,11 +13,13 @@ import (

// GetValidatorData returns metadata (balance, index, status, more) for each pubkey from the node
func (gc *GoClient) GetValidatorData(validatorPubKeys []phase0.BLSPubKey) (map[phase0.ValidatorIndex]*eth2apiv1.Validator, error) {
reqStart := time.Now()
resp, err := gc.client.Validators(gc.ctx, &api.ValidatorsOpts{
State: "head", // TODO maybe need to get the chainId (head) as var
PubKeys: validatorPubKeys,
Common: api.CommonOpts{Timeout: gc.longTimeout},
})
recordRequestDuration(gc.ctx, "Validators", gc.client.Address(), http.MethodPost, time.Since(reqStart), err)
if err != nil {
gc.log.Error(clResponseErrMsg,
zap.String("api", "Validators"),
Expand Down

0 comments on commit c57d7f5

Please sign in to comment.