Skip to content

Commit

Permalink
refactoring metrics (#564)
Browse files Browse the repository at this point in the history
Signed-off-by: Fedor Partanskiy <[email protected]>
Co-authored-by: C0rWin <[email protected]>
  • Loading branch information
pfi79 and C0rWin authored Sep 3, 2023
1 parent 154c866 commit 1c03930
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 164 deletions.
4 changes: 2 additions & 2 deletions internal/bft/requestpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (rp *Pool) Submit(request []byte) error {

if uint64(len(request)) > rp.options.RequestMaxBytes {
rp.metrics.CountOfFailAddRequestToPool.With(
rp.metrics.LabelsForWith(api.NameReasonFailAdd, api.ReasonRequestMaxBytes)...,
rp.metrics.LabelsForWith("reason", api.ReasonRequestMaxBytes)...,
).Add(1)
return fmt.Errorf(
"submitted request (%d) is bigger than request max bytes (%d)",
Expand Down Expand Up @@ -217,7 +217,7 @@ func (rp *Pool) Submit(request []byte) error {
// do not wait for a semaphore with a lock, as it will prevent draining the pool.
if err := rp.semaphore.Acquire(ctx, 1); err != nil {
rp.metrics.CountOfFailAddRequestToPool.With(
rp.metrics.LabelsForWith(api.NameReasonFailAdd, api.ReasonSemaphoreAcquireFail)...,
rp.metrics.LabelsForWith("reason", api.ReasonSemaphoreAcquireFail)...,
).Add(1)
return errors.Wrapf(err, "acquiring semaphore for request: %s", reqInfo)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/bft/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ func (bl blacklist) computeUpdate() []uint64 {
for _, node := range bl.nodes {
inBlacklist := newBlacklistMap[node]
bl.metricsBlacklist.NodesInBlackList.With(
bl.metricsBlacklist.LabelsForWith(api.NameBlackListNodeID, strconv.FormatUint(node, 10))...,
bl.metricsBlacklist.LabelsForWith("blackid", strconv.FormatUint(node, 10))...,
).Set(btoi(inBlacklist))
}
bl.metricsBlacklist.CountBlackList.Set(float64(len(newBlacklist)))
Expand Down
Loading

0 comments on commit 1c03930

Please sign in to comment.