Skip to content

Commit

Permalink
go/runtime/txpool: Add txpool metric for rejected runtime transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed May 3, 2022
1 parent 3a0058a commit 06e955c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/4724.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/runtime/txpool: Add txpool metric for rejected runtime transactions
2 changes: 2 additions & 0 deletions docs/oasis-node/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ oasis_storage_failures | Counter | Number of storage failures. | call | [storage
oasis_storage_latency | Summary | Storage call latency (seconds). | call | [storage/api](https://github.com/oasisprotocol/oasis-core/tree/master/go/storage/api/metrics.go)
oasis_storage_successes | Counter | Number of storage successes. | call | [storage/api](https://github.com/oasisprotocol/oasis-core/tree/master/go/storage/api/metrics.go)
oasis_storage_value_size | Summary | Storage call value size (bytes). | call | [storage/api](https://github.com/oasisprotocol/oasis-core/tree/master/go/storage/api/metrics.go)
oasis_txpool_accepted_transactions | Counter | Number of accepted transactions (passing check tx). | runtime | [runtime/txpool](https://github.com/oasisprotocol/oasis-core/tree/master/go/runtime/txpool/metrics.go)
oasis_txpool_pending_check_size | Gauge | Size of the pending to be checked queue (number of entries). | runtime | [runtime/txpool](https://github.com/oasisprotocol/oasis-core/tree/master/go/runtime/txpool/metrics.go)
oasis_txpool_pending_schedule_size | Gauge | Size of the pending to be scheduled queue (number of entries). | runtime | [runtime/txpool](https://github.com/oasisprotocol/oasis-core/tree/master/go/runtime/txpool/metrics.go)
oasis_txpool_rejected_transactions | Counter | Number of rejected transactions (failing check tx). | runtime | [runtime/txpool](https://github.com/oasisprotocol/oasis-core/tree/master/go/runtime/txpool/metrics.go)
oasis_up | Gauge | Is oasis-test-runner active for specific scenario. | | [oasis-node/cmd/common/metrics](https://github.com/oasisprotocol/oasis-core/tree/master/go/oasis-node/cmd/common/metrics/metrics.go)
oasis_worker_aborted_batch_count | Counter | Number of aborted batches. | runtime | [worker/compute/executor/committee](https://github.com/oasisprotocol/oasis-core/tree/master/go/worker/compute/executor/committee/node.go)
oasis_worker_batch_processing_time | Summary | Time it takes for a batch to finalize (seconds). | runtime | [worker/compute/executor/committee](https://github.com/oasisprotocol/oasis-core/tree/master/go/worker/compute/executor/committee/node.go)
Expand Down
16 changes: 16 additions & 0 deletions go/runtime/txpool/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,25 @@ var (
},
[]string{"runtime"},
)
rejectedTransactions = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "oasis_txpool_rejected_transactions",
Help: "Number of rejected transactions (failing check tx).",
},
[]string{"runtime"},
)
acceptedTransactions = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "oasis_txpool_accepted_transactions",
Help: "Number of accepted transactions (passing check tx).",
},
[]string{"runtime"},
)
txpoolCollectors = []prometheus.Collector{
pendingCheckSize,
pendingScheduleSize,
rejectedTransactions,
acceptedTransactions,
}

metricsOnce sync.Once
Expand Down
2 changes: 2 additions & 0 deletions go/runtime/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ func (t *txPool) checkTxBatch(ctx context.Context, rr host.RichRuntime) {
var unschedule []hash.Hash
for i, res := range results {
if !res.IsSuccess() {
rejectedTransactions.With(t.getMetricLabels()).Inc()
t.logger.Debug("check tx failed",
"tx", batch[i].tx,
"tx_hash", batch[i].hash,
Expand All @@ -525,6 +526,7 @@ func (t *txPool) checkTxBatch(ctx context.Context, rr host.RichRuntime) {

// For any transactions that are to be queued, we defer notification until queued.

acceptedTransactions.With(t.getMetricLabels()).Inc()
batch[i].setChecked(res.Meta)
newTxs = append(newTxs, batch[i])
batchIndices = append(batchIndices, i)
Expand Down

0 comments on commit 06e955c

Please sign in to comment.