Skip to content

Commit 6333e56

Browse files

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
 

‎state/execution.go

+6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ func (blockExec *BlockExecutor) CreateProposalBlock(
146146
panic(err)
147147
}
148148
rawNewData := preparedProposal.GetBlockData()
149+
150+
rejectedTxs := len(rawNewData.Txs) - len(txs)
151+
if rejectedTxs > 0 {
152+
blockExec.metrics.RejectedTransactions.Add(float64(rejectedTxs))
153+
}
154+
149155
var blockDataSize int
150156
for _, tx := range rawNewData.GetTxs() {
151157
blockDataSize += len(tx)

‎state/metrics.go

+9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type Metrics struct {
1919
BlockProcessingTime metrics.Histogram
2020
// Count of times a block was rejected via ProcessProposal
2121
ProcessProposalRejected metrics.Counter
22+
// Count of transactions rejected by application.
23+
RejectedTransactions metrics.Counter
2224
}
2325

2426
// PrometheusMetrics returns Metrics build using Prometheus client library.
@@ -43,6 +45,12 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
4345
Name: "process_proposal_rejected",
4446
Help: "Count of times a block was rejected via ProcessProposal",
4547
}, labels).With(labelsAndValues...),
48+
RejectedTransactions: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
49+
Namespace: namespace,
50+
Subsystem: MetricsSubsystem,
51+
Name: "rejected_transactions",
52+
Help: "Count of transactions rejected by application",
53+
}, labels).With(labelsAndValues...),
4654
}
4755
}
4856

@@ -51,5 +59,6 @@ func NopMetrics() *Metrics {
5159
return &Metrics{
5260
BlockProcessingTime: discard.NewHistogram(),
5361
ProcessProposalRejected: discard.NewCounter(),
62+
RejectedTransactions: discard.NewCounter(),
5463
}
5564
}

0 commit comments

Comments
 (0)
Please sign in to comment.