Commit cdf3a602 authored by Sebastian Stammler's avatar Sebastian Stammler Committed by GitHub

txmgr: add tx-type metric (#11523)

parent 116b6e62
...@@ -24,11 +24,12 @@ type TxMetricer interface { ...@@ -24,11 +24,12 @@ type TxMetricer interface {
} }
type TxMetrics struct { type TxMetrics struct {
TxL1GasFee prometheus.Gauge txL1GasFee prometheus.Gauge
txFees prometheus.Counter txFeesTotal prometheus.Counter
TxGasBump prometheus.Gauge txGasBump prometheus.Gauge
txFeeHistogram prometheus.Histogram txFeeHistogram prometheus.Histogram
LatencyConfirmedTx prometheus.Gauge txType prometheus.Gauge
latencyConfirmedTx prometheus.Gauge
currentNonce prometheus.Gauge currentNonce prometheus.Gauge
pendingTxs prometheus.Gauge pendingTxs prometheus.Gauge
txPublishError *prometheus.CounterVec txPublishError *prometheus.CounterVec
...@@ -55,18 +56,24 @@ var _ TxMetricer = (*TxMetrics)(nil) ...@@ -55,18 +56,24 @@ var _ TxMetricer = (*TxMetrics)(nil)
func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics { func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
return TxMetrics{ return TxMetrics{
TxL1GasFee: factory.NewGauge(prometheus.GaugeOpts{ txL1GasFee: factory.NewGauge(prometheus.GaugeOpts{
Namespace: ns, Namespace: ns,
Name: "tx_fee_gwei", Name: "tx_fee_gwei",
Help: "L1 gas fee for transactions in GWEI", Help: "L1 gas fee for transactions in GWEI",
Subsystem: "txmgr", Subsystem: "txmgr",
}), }),
txFees: factory.NewCounter(prometheus.CounterOpts{ txFeesTotal: factory.NewCounter(prometheus.CounterOpts{
Namespace: ns, Namespace: ns,
Name: "tx_fee_gwei_total", Name: "tx_fee_gwei_total",
Help: "Sum of fees spent for all transactions in GWEI", Help: "Sum of fees spent for all transactions in GWEI",
Subsystem: "txmgr", Subsystem: "txmgr",
}), }),
txGasBump: factory.NewGauge(prometheus.GaugeOpts{
Namespace: ns,
Name: "tx_gas_bump",
Help: "Number of times a transaction gas needed to be bumped before it got included",
Subsystem: "txmgr",
}),
txFeeHistogram: factory.NewHistogram(prometheus.HistogramOpts{ txFeeHistogram: factory.NewHistogram(prometheus.HistogramOpts{
Namespace: ns, Namespace: ns,
Name: "tx_fee_histogram_gwei", Name: "tx_fee_histogram_gwei",
...@@ -74,13 +81,13 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics { ...@@ -74,13 +81,13 @@ func MakeTxMetrics(ns string, factory metrics.Factory) TxMetrics {
Subsystem: "txmgr", Subsystem: "txmgr",
Buckets: []float64{0.5, 1, 2, 5, 10, 20, 40, 60, 80, 100, 200, 400, 800, 1600}, Buckets: []float64{0.5, 1, 2, 5, 10, 20, 40, 60, 80, 100, 200, 400, 800, 1600},
}), }),
TxGasBump: factory.NewGauge(prometheus.GaugeOpts{ txType: factory.NewGauge(prometheus.GaugeOpts{
Namespace: ns, Namespace: ns,
Name: "tx_gas_bump", Name: "tx_type",
Help: "Number of times a transaction gas needed to be bumped before it got included", Help: "Transaction type (receipt field uint8)",
Subsystem: "txmgr", Subsystem: "txmgr",
}), }),
LatencyConfirmedTx: factory.NewGauge(prometheus.GaugeOpts{ latencyConfirmedTx: factory.NewGauge(prometheus.GaugeOpts{
Namespace: ns, Namespace: ns,
Name: "tx_confirmed_latency_ms", Name: "tx_confirmed_latency_ms",
Help: "Latency of a confirmed transaction in milliseconds", Help: "Latency of a confirmed transaction in milliseconds",
...@@ -145,17 +152,18 @@ func (t *TxMetrics) RecordPendingTx(pending int64) { ...@@ -145,17 +152,18 @@ func (t *TxMetrics) RecordPendingTx(pending int64) {
func (t *TxMetrics) TxConfirmed(receipt *types.Receipt) { func (t *TxMetrics) TxConfirmed(receipt *types.Receipt) {
fee := float64(receipt.EffectiveGasPrice.Uint64() * receipt.GasUsed / params.GWei) fee := float64(receipt.EffectiveGasPrice.Uint64() * receipt.GasUsed / params.GWei)
t.confirmEvent.Record(receiptStatusString(receipt)) t.confirmEvent.Record(receiptStatusString(receipt))
t.TxL1GasFee.Set(fee) t.txL1GasFee.Set(fee)
t.txFees.Add(fee) t.txFeesTotal.Add(fee)
t.txFeeHistogram.Observe(fee) t.txFeeHistogram.Observe(fee)
t.txType.Set(float64(receipt.Type))
} }
func (t *TxMetrics) RecordGasBumpCount(times int) { func (t *TxMetrics) RecordGasBumpCount(times int) {
t.TxGasBump.Set(float64(times)) t.txGasBump.Set(float64(times))
} }
func (t *TxMetrics) RecordTxConfirmationLatency(latency int64) { func (t *TxMetrics) RecordTxConfirmationLatency(latency int64) {
t.LatencyConfirmedTx.Set(float64(latency)) t.latencyConfirmedTx.Set(float64(latency))
} }
func (t *TxMetrics) TxPublished(errString string) { func (t *TxMetrics) TxPublished(errString string) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment