Skip to content

Commit

Permalink
observability: add metrics to exporter api
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolie-ssv committed Dec 2, 2024
1 parent b6bed67 commit 7469891
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exporter/api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ var (
Name: "ssv:exporter:stream_outbound_errors",
Help: "count the outbound messages failures on stream channel",
}, []string{"cid"})
metricHandleParticipantsQueryReq = promauto.NewHistogramVec(prometheus.HistogramOpts{
Name: "ssv:exporter:handle_participants_query_req",
Help: "Histogram of HTTP request durations in seconds.",
}, []string{"role"})
)

func reportStreamOutbound(cid string, err error) {
Expand Down
4 changes: 4 additions & 0 deletions exporter/api/query_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package api
import (
"encoding/hex"
"fmt"
"time"

"github.com/attestantio/go-eth2-client/spec/phase0"
spectypes "github.com/ssvlabs/ssv-spec/types"
Expand Down Expand Up @@ -49,6 +50,9 @@ func HandleUnknownQuery(logger *zap.Logger, nm *NetworkMessage) {

// HandleParticipantsQuery handles TypeParticipants queries.
func HandleParticipantsQuery(logger *zap.Logger, qbftStorage *storage.QBFTStores, nm *NetworkMessage, domain spectypes.DomainType) {
sinceStart := time.Since(time.Now())
defer metricHandleParticipantsQueryReq.WithLabelValues(nm.Msg.Filter.Role).Observe(sinceStart.Seconds())

logger.Debug("handles query request",
zap.Uint64("from", nm.Msg.Filter.From),
zap.Uint64("to", nm.Msg.Filter.To),
Expand Down

0 comments on commit 7469891

Please sign in to comment.