Skip to content

Commit

Permalink
Merge pull request #398 from ava-labs/get-ancestors-metrics
Browse files Browse the repository at this point in the history
Add metrics to track the number of vtx/blocks put into MultiPut msgs
  • Loading branch information
StephenButtolph authored Sep 13, 2020
2 parents 41e3ced + e6b8470 commit 3c73ab9
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 8 deletions.
4 changes: 4 additions & 0 deletions network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ func (n *network) GetAcceptedFrontier(validatorIDs ids.ShortSet, chainID ids.ID,
sent = peer.send(msg)
}
if !sent {
n.log.Debug("failed to send GetAcceptedFrontier(%s, %s, %d)",
vID,
chainID,
requestID)
n.executor.Add(func() { n.router.GetAcceptedFrontierFailed(vID, chainID, requestID) })
n.getAcceptedFrontier.numFailed.Inc()
} else {
Expand Down
18 changes: 18 additions & 0 deletions snow/engine/avalanche/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

type metrics struct {
numVtxRequests, numPendingVts, numMissingTxs prometheus.Gauge
getAncestorsVtxs prometheus.Histogram
}

// Initialize implements the Engine interface
Expand All @@ -30,12 +31,29 @@ func (m *metrics) Initialize(namespace string, registerer prometheus.Registerer)
Name: "missing_txs",
Help: "Number of missing transactions",
})
m.getAncestorsVtxs = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "get_ancestors_vtxs",
Help: "The number of vertices fetched in a call to GetAncestors",
Buckets: []float64{
0,
1,
5,
10,
100,
500,
1000,
1500,
2000,
},
})

errs := wrappers.Errs{}
errs.Add(
registerer.Register(m.numVtxRequests),
registerer.Register(m.numPendingVts),
registerer.Register(m.numMissingTxs),
registerer.Register(m.getAncestorsVtxs),
)
return errs.Err
}
1 change: 1 addition & 0 deletions snow/engine/avalanche/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func (t *Transitive) GetAncestors(vdr ids.ShortID, requestID uint32, vtxID ids.I
}
}

t.metrics.getAncestorsVtxs.Observe(float64(len(ancestorsBytes)))
t.Sender.MultiPut(vdr, requestID, ancestorsBytes)
return nil
}
Expand Down
18 changes: 18 additions & 0 deletions snow/engine/snowman/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

type metrics struct {
numRequests, numBlocked prometheus.Gauge
getAncestorsBlks prometheus.Histogram
}

// Initialize the metrics
Expand All @@ -25,11 +26,28 @@ func (m *metrics) Initialize(namespace string, registerer prometheus.Registerer)
Name: "blocked",
Help: "Number of blocks that are pending issuance",
})
m.getAncestorsBlks = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: namespace,
Name: "get_ancestors_blks",
Help: "The number of blocks fetched in a call to GetAncestors",
Buckets: []float64{
0,
1,
5,
10,
100,
500,
1000,
1500,
2000,
},
})

errs := wrappers.Errs{}
errs.Add(
registerer.Register(m.numRequests),
registerer.Register(m.numBlocked),
registerer.Register(m.getAncestorsBlks),
)
return errs.Err
}
1 change: 1 addition & 0 deletions snow/engine/snowman/transitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ func (t *Transitive) GetAncestors(vdr ids.ShortID, requestID uint32, blkID ids.I
}
}

t.metrics.getAncestorsBlks.Observe(float64(len(ancestorsBytes)))
t.Sender.MultiPut(vdr, requestID, ancestorsBytes)
return nil
}
Expand Down
10 changes: 5 additions & 5 deletions snow/networking/router/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,26 +394,26 @@ func (h *Handler) GetFailed(validatorID ids.ShortID, requestID uint32) {
}

// PushQuery passes a PushQuery message received from the network to the consensus engine.
func (h *Handler) PushQuery(validatorID ids.ShortID, requestID uint32, deadline time.Time, blockID ids.ID, block []byte) bool {
func (h *Handler) PushQuery(validatorID ids.ShortID, requestID uint32, deadline time.Time, containerID ids.ID, container []byte) bool {
return h.serviceQueue.PushMessage(message{
messageType: pushQueryMsg,
validatorID: validatorID,
requestID: requestID,
deadline: deadline,
containerID: blockID,
container: block,
containerID: containerID,
container: container,
received: h.clock.Time(),
})
}

// PullQuery passes a PullQuery message received from the network to the consensus engine.
func (h *Handler) PullQuery(validatorID ids.ShortID, requestID uint32, deadline time.Time, blockID ids.ID) bool {
func (h *Handler) PullQuery(validatorID ids.ShortID, requestID uint32, deadline time.Time, containerID ids.ID) bool {
return h.serviceQueue.PushMessage(message{
messageType: pullQueryMsg,
validatorID: validatorID,
requestID: requestID,
deadline: deadline,
containerID: blockID,
containerID: containerID,
received: h.clock.Time(),
})
}
Expand Down
11 changes: 8 additions & 3 deletions snow/networking/router/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ func (m message) String() string {
sb.WriteString(fmt.Sprintf("\n messageType: %s", m.messageType))
sb.WriteString(fmt.Sprintf("\n validatorID: %s", m.validatorID))
sb.WriteString(fmt.Sprintf("\n requestID: %d", m.requestID))
sb.WriteString(fmt.Sprintf("\n containerID: %s", m.containerID))
sb.WriteString(fmt.Sprintf("\n containerIDs: %s", m.containerIDs))
if m.messageType == notifyMsg {
switch m.messageType {
case getAcceptedMsg, acceptedMsg, chitsMsg:
sb.WriteString(fmt.Sprintf("\n containerIDs: %s", m.containerIDs))
case getMsg, getAncestorsMsg, putMsg, pushQueryMsg, pullQueryMsg:
sb.WriteString(fmt.Sprintf("\n containerID: %s", m.containerID))
case multiPutMsg:
sb.WriteString(fmt.Sprintf("\n numContainers: %d", len(m.containers)))
case notifyMsg:
sb.WriteString(fmt.Sprintf("\n notification: %s", m.notification))
}
if !m.deadline.IsZero() {
Expand Down

0 comments on commit 3c73ab9

Please sign in to comment.