Commit f46c1e29 authored by Henri Devieux's avatar Henri Devieux Committed by GitHub

Emit histogram for blob size (#9233)

* Emit gauge for blob size

* use histogram instead of gauge

* add buckets
parent 254367c0
......@@ -372,6 +372,7 @@ func (l *BatchSubmitter) sendTransaction(txdata txData, queue *txmgr.Queue[txDat
// or configuration issue.
return fmt.Errorf("could not create blob tx candidate: %w", err)
}
l.Metr.RecordBlobUsedBytes(len(data))
} else {
candidate = l.calldataTxCandidate(data)
}
......
......@@ -46,6 +46,8 @@ type Metricer interface {
RecordBatchTxSuccess()
RecordBatchTxFailed()
RecordBlobUsedBytes(num int)
Document() []opmetrics.DocumentedMetric
}
......@@ -79,6 +81,8 @@ type Metrics struct {
channelOutputBytesTotal prometheus.Counter
batcherTxEvs opmetrics.EventVec
blobUsedBytes prometheus.Histogram
}
var _ Metricer = (*Metrics)(nil)
......@@ -181,6 +185,12 @@ func NewMetrics(procName string) *Metrics {
Name: "output_bytes_total",
Help: "Total number of compressed output bytes from a channel.",
}),
blobUsedBytes: factory.NewHistogram(prometheus.HistogramOpts{
Namespace: ns,
Name: "blob_used_bytes",
Help: "Blob size in bytes being submitted.",
Buckets: prometheus.LinearBuckets(0.0, eth.MaxBlobDataSize/13, 13),
}),
batcherTxEvs: opmetrics.NewEventVec(factory, ns, "", "batcher_tx", "BatcherTx", []string{"stage"}),
}
......@@ -304,6 +314,10 @@ func (m *Metrics) RecordBatchTxFailed() {
m.batcherTxEvs.Record(TxStageFailed)
}
func (m *Metrics) RecordBlobUsedBytes(num int) {
m.blobUsedBytes.Observe(float64(num))
}
// estimateBatchSize estimates the size of the batch
func estimateBatchSize(block *types.Block) uint64 {
size := uint64(70) // estimated overhead of batch metadata
......
......@@ -42,6 +42,7 @@ func (*noopMetrics) RecordChannelTimedOut(derive.ChannelID) {}
func (*noopMetrics) RecordBatchTxSubmitted() {}
func (*noopMetrics) RecordBatchTxSuccess() {}
func (*noopMetrics) RecordBatchTxFailed() {}
func (*noopMetrics) RecordBlobUsedBytes(int) {}
func (*noopMetrics) StartBalanceMetrics(log.Logger, *ethclient.Client, common.Address) io.Closer {
return nil
}
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