Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cosmos_relayer_tx_failure metric redundant count #1343

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions relayer/processor/message_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ type messageProcessor struct {
}

// catagories of tx errors for a Prometheus counter. If the error doesnt fall into one of the below categories, it is labeled as "Tx Failure"
var promErrorCatagories = []error{chantypes.ErrRedundantTx, legacyerrors.ErrInsufficientFunds, legacyerrors.ErrInvalidCoins, legacyerrors.ErrOutOfGas, legacyerrors.ErrWrongSequence}
var promErrorCatagories = []error{
chantypes.ErrRedundantTx,
legacyerrors.ErrInsufficientFunds,
legacyerrors.ErrInvalidCoins,
legacyerrors.ErrOutOfGas,
legacyerrors.ErrWrongSequence,
}

// trackMessage stores the message tracker in the correct slice and index based on the type.
func (mp *messageProcessor) trackMessage(tracker messageToTrack, i int) {
Expand Down Expand Up @@ -374,15 +380,7 @@ func (mp *messageProcessor) sendClientUpdate(
zap.Error(err),
)

for _, promError := range promErrorCatagories {
if mp.metrics != nil {
if errors.Is(err, promError) {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, promError.Error())
} else {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, "Tx Failure")
}
}
}
mp.metricParseTxFailureCatagory(err, src)
return
}
dst.log.Debug("Client update broadcast completed")
Expand Down Expand Up @@ -477,15 +475,7 @@ func (mp *messageProcessor) sendBatchMessages(
zap.Error(err),
}

for _, promError := range promErrorCatagories {
if mp.metrics != nil {
if errors.Is(err, promError) {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, promError.Error())
} else {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, "Tx Failure")
}
}
}
mp.metricParseTxFailureCatagory(err, src)

if errors.Is(err, chantypes.ErrRedundantTx) {
mp.log.Debug("Redundant message(s)", errFields...)
Expand Down Expand Up @@ -564,15 +554,7 @@ func (mp *messageProcessor) sendSingleMessage(
zap.String("dst_client_id", dst.info.ClientID),
}

for _, promError := range promErrorCatagories {
if mp.metrics != nil {
if errors.Is(err, promError) {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, promError.Error())
} else {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, "Tx Failure")
}
}
}
mp.metricParseTxFailureCatagory(err, src)

errFields = append(errFields, zap.Object("msg", tracker))
errFields = append(errFields, zap.Error(err))
Expand All @@ -586,3 +568,21 @@ func (mp *messageProcessor) sendSingleMessage(

dst.log.Debug(fmt.Sprintf("Successfully broadcasted %s message", msgType), zap.Object("msg", tracker))
}

func (mp *messageProcessor) metricParseTxFailureCatagory(err error, src *pathEndRuntime) {
if mp.metrics == nil {
return
}

found := false
for _, promError := range promErrorCatagories {
if errors.Is(err, promError) {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, promError.Error())
found = true
boojamya marked this conversation as resolved.
Show resolved Hide resolved
break
}
}
if !found {
mp.metrics.IncTxFailure(src.info.PathName, src.info.ChainID, "Tx Failure")
}
}
Loading