Skip to content

Commit

Permalink
Add generic algod_transaction_messages_backlog_err metric
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed Nov 16, 2022
1 parent 5fd63cb commit 96d46e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 4 additions & 1 deletion data/txHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var transactionMessagesTxnSigNotWellFormed = metrics.MakeCounter(metrics.Transac
var transactionMessagesTxnMsigNotWellFormed = metrics.MakeCounter(metrics.TransactionMessagesTxnMsigNotWellFormed)
var transactionMessagesTxnLogicSig = metrics.MakeCounter(metrics.TransactionMessagesTxnLogicSig)
var transactionMessagesTxnSigVerificationFailed = metrics.MakeCounter(metrics.TransactionMessagesTxnSigVerificationFailed)
var transactionMessagesBacklogErr = metrics.MakeCounter(metrics.TransactionMessagesBacklogErr)
var transactionMessagesBacklogSizeGauge = metrics.MakeGauge(metrics.TransactionMessagesBacklogSize)

var transactionGroupTxSyncRemember = metrics.MakeCounter(metrics.TransactionGroupTxSyncRemember)
Expand Down Expand Up @@ -201,7 +202,6 @@ func (handler *TxHandler) postProcessReportErrors(err error) {

var txGroupErr *verify.ErrTxGroupError
if errors.As(err, &txGroupErr) {
// txGroupErr = err.(*verify.ErrTxGroupError)
switch txGroupErr.Reason {
case verify.TxGroupErrorReasonNotWellFormed:
transactionMessagesTxnNotWellFormed.Inc(nil)
Expand All @@ -216,7 +216,10 @@ func (handler *TxHandler) postProcessReportErrors(err error) {
case verify.TxGroupErrorReasonLogicSigFailed:
transactionMessagesTxnLogicSig.Inc(nil)
default:
transactionMessagesBacklogErr.Inc(nil)
}
} else {
transactionMessagesBacklogErr.Inc(nil)
}
}

Expand Down
9 changes: 6 additions & 3 deletions data/txHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -570,16 +570,17 @@ func runHandlerBenchmark(maxGroupSize int, b *testing.B) {
wg.Wait()
}

func TestPostProcessError(t *testing.T) {
func TestTxHandlerPostProcessError(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

collect := func() map[string]float64 {
// collect all specific error reason metrics except TxGroupErrorReasonNotWellFormed,
// it is tested in TestPostProcessErrorWithVerify
result := map[string]float64{}
transactionMessagesTxnSigVerificationFailed.AddMetric(result)
transactionMessagesAlreadyCommitted.AddMetric(result)
transactionMessagesTxGroupInvalidFee.AddMetric(result)
// exclude TxGroupErrorReasonNotWellFormed, tested in TestPostProcessErrorWithVerify
// transactionMessagesTxnNotWellFormed.AddMetric(result)
transactionMessagesTxnSigNotWellFormed.AddMetric(result)
transactionMessagesTxnMsigNotWellFormed.AddMetric(result)
Expand All @@ -592,6 +593,8 @@ func TestPostProcessError(t *testing.T) {
txh.postProcessReportErrors(errSome)
result := collect()
require.Len(t, result, 0)
transactionMessagesBacklogErr.AddMetric(result)
require.Len(t, result, 1)

counter := 0
for i := verify.TxGroupErrorReasonGeneric; i <= verify.TxGroupErrorReasonLogicSigFailed; i++ {
Expand Down Expand Up @@ -624,7 +627,7 @@ func TestPostProcessError(t *testing.T) {
require.Len(t, result, expected+1)
}

func TestPostProcessErrorWithVerify(t *testing.T) {
func TestTxHandlerPostProcessErrorWithVerify(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

Expand Down
6 changes: 4 additions & 2 deletions util/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ var (
// TransactionMessagesDroppedFromPool "Number of transaction messages dropped from pool"
TransactionMessagesDroppedFromPool = MetricName{Name: "algod_transaction_messages_dropped_pool", Description: "Number of transaction messages dropped from pool"}
// TransactionMessagesAlreadyCommitted "Number of duplicate or error transaction messages before placing into a backlog"
TransactionMessagesAlreadyCommitted = MetricName{Name: "algod_transaction_messages_already_committed", Description: "Number of duplicate or error transaction messages after txhandler backlog"}
TransactionMessagesAlreadyCommitted = MetricName{Name: "algod_transaction_messages_err_or_committed", Description: "Number of duplicate or error transaction messages after txhandler backlog"}
// TransactionMessagesTxGroupInvalidFee "Number of transaction messages with invalid txgroup fee"
TransactionMessagesTxGroupInvalidFee = MetricName{Name: "algod_transaction_messages_txgroup_invalid_fee", Description: "Number of transaction messages with invalid txgroup fee"}
// TransactionMessagesTxnNotWellFormed "Number of transaction messages not well formed"
Expand All @@ -105,11 +105,13 @@ var (
TransactionMessagesTxnLogicSig = MetricName{Name: "algod_transaction_messages_logic_sig_failed", Description: "Number of transaction messages with invalid logic sig"}
// TransactionMessagesTxnSigVerificationFailed "Number of transaction messages with signature verification failed"
TransactionMessagesTxnSigVerificationFailed = MetricName{Name: "algod_transaction_messages_sig_verify_failed", Description: "Number of transaction messages with signature verification failed"}
// TransactionMessagesBacklogErr "Number of transaction messages with some validation error"
TransactionMessagesBacklogErr = MetricName{Name: "algod_transaction_messages_backlog_err", Description: "Number of transaction messages with some validation error"}
// TransactionMessagesBacklogSize "Number of transaction messages in the TX handler backlog queue"
TransactionMessagesBacklogSize = MetricName{Name: "algod_transaction_messages_backlog_size", Description: "Number of transaction messages in the TX handler backlog queue"}

// TransactionGroupTxSyncRemember "Number of transaction groups remembered via tx sync"
TransactionGroupTxSyncRemember = MetricName{Name: "algod_transaction_group_txsync_remember", Description: "Number of transaction groups remembered via txsync"}
// TransactionGroupTxSyncAlreadyCommitted "Number of duplicate or error transaction groups received via txsync"
TransactionGroupTxSyncAlreadyCommitted = MetricName{Name: "algod_transaction_group_txsync_already_committed", Description: "Number of duplicate or error transaction groups received via txsync"}
TransactionGroupTxSyncAlreadyCommitted = MetricName{Name: "algod_transaction_group_txsync_err_or_committed", Description: "Number of duplicate or error transaction groups received via txsync"}
)

0 comments on commit 96d46e5

Please sign in to comment.