Skip to content

Commit

Permalink
add some batch metric
Browse files Browse the repository at this point in the history
  • Loading branch information
HXHke committed Sep 26, 2023
1 parent f877f61 commit 5d987cd
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions batch-submitter/drivers/sequencer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ func (d *Driver) CraftBatchTx(
BlockNumber: lastBlockNumber,
}

d.metrics.BatchNumSequencedTxs().Set(float64(batchContext.NumSequencedTxs))
d.metrics.BatchNumSubsequentQueueTxs().Set(float64(batchContext.NumSubsequentQueueTxs))
d.metrics.BatchTimestamp().Set(float64(batchContext.Timestamp))
d.metrics.BatchBlockNumber().Set(float64(batchContext.BlockNumber))

contexts = append(contexts, batchContext)
batchParams := &AppendSequencerBatchParams{
ShouldStartAtElement: shouldStartAt - d.cfg.BlockOffset,
Expand Down
12 changes: 12 additions & 0 deletions bss-core/metrics/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,16 @@ type Metrics interface {

// SccRollupTimeDuration state root rollup time duration
SccRollupTimeDuration() prometheus.Gauge

// BatchNumSequencedTxs Number of batch sequenced transactions
BatchNumSequencedTxs() prometheus.Gauge

// BatchNumSubsequentQueueTxs Number of batch subsequent queue transactions
BatchNumSubsequentQueueTxs() prometheus.Gauge

// BatchTimestamp Timestamp of batch
BatchTimestamp() prometheus.Gauge

// BatchBlockNumber Block number of batch
BatchBlockNumber() prometheus.Gauge
}
48 changes: 48 additions & 0 deletions bss-core/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ type Base struct {

// sccRollupTimeDuration state root rollup time duration
sccRollupTimeDuration prometheus.Gauge

batchNumSequencedTxs prometheus.Gauge

batchNumSubsequentQueueTxs prometheus.Gauge

batchTimestamp prometheus.Gauge

batchBlockNumber prometheus.Gauge
}

func NewBase(serviceName, subServiceName string) *Base {
Expand Down Expand Up @@ -121,6 +129,26 @@ func NewBase(serviceName, subServiceName string) *Base {
Help: "state root rollup time duration",
Subsystem: subsystem,
}),
batchNumSequencedTxs: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_num_sequenced_txs",
Help: "Number of batch sequenced transactions",
Subsystem: subsystem,
}),
batchNumSubsequentQueueTxs: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_num_subsequent_queue_txs",
Help: "Number of batch subsequent queue transactions",
Subsystem: subsystem,
}),
batchTimestamp: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_timestamp",
Help: "Timestamp of batch",
Subsystem: subsystem,
}),
batchBlockNumber: promauto.NewGauge(prometheus.GaugeOpts{
Name: "batch_block_number",
Help: "Block number of batch",
Subsystem: subsystem,
}),
}
}

Expand Down Expand Up @@ -187,6 +215,26 @@ func (b *Base) SccRollupTimeDuration() prometheus.Gauge {
return b.sccRollupTimeDuration
}

// BatchNumSequencedTxs Number of batch sequenced transactions
func (b *Base) BatchNumSequencedTxs() prometheus.Gauge {
return b.batchNumSequencedTxs
}

// BatchNumSubsequentQueueTxs Number of batch subsequent queue transactions
func (b *Base) BatchNumSubsequentQueueTxs() prometheus.Gauge {
return b.batchNumSubsequentQueueTxs
}

// BatchTimestamp Timestamp of batch
func (b *Base) BatchTimestamp() prometheus.Gauge {
return b.batchTimestamp
}

// BatchBlockNumber Block number of batch
func (b *Base) BatchBlockNumber() prometheus.Gauge {
return b.batchBlockNumber
}

// MakeSubsystemName builds the subsystem name for a group of metrics, which
// prometheus will use to prefix all metrics in the group. If two non-empty
// strings are provided, they are joined with an underscore. If only one
Expand Down

0 comments on commit 5d987cd

Please sign in to comment.