Commit 768cb10d authored by Tei Im's avatar Tei Im

Add derived batch metrics

parent 56f994c9
......@@ -46,6 +46,8 @@ type Metricer interface {
RecordL1Ref(name string, ref eth.L1BlockRef)
RecordL2Ref(name string, ref eth.L2BlockRef)
RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)
RecordDerivedSingularBatches()
RecordDerivedSpanBatches()
CountSequencedTxs(count int)
RecordL1ReorgDepth(d uint64)
RecordSequencerInconsistentL1Origin(from eth.BlockID, to eth.BlockID)
......@@ -93,6 +95,9 @@ type Metrics struct {
SequencingErrors *metrics.Event
PublishingErrors *metrics.Event
DerivedSingularBatches *metrics.Event
DerivedSpanBatches *metrics.Event
P2PReqDurationSeconds *prometheus.HistogramVec
P2PReqTotal *prometheus.CounterVec
P2PPayloadByNumber *prometheus.GaugeVec
......@@ -192,6 +197,9 @@ func NewMetrics(procName string) *Metrics {
SequencingErrors: metrics.NewEvent(factory, ns, "", "sequencing_errors", "sequencing errors"),
PublishingErrors: metrics.NewEvent(factory, ns, "", "publishing_errors", "p2p publishing errors"),
DerivedSingularBatches: metrics.NewEvent(factory, ns, "", "derived_singular_batches", "derived singular batches"),
DerivedSpanBatches: metrics.NewEvent(factory, ns, "", "derived_span_batches", "derived span batches"),
SequencerInconsistentL1Origin: metrics.NewEvent(factory, ns, "", "sequencer_inconsistent_l1_origin", "events when the sequencer selects an inconsistent L1 origin"),
SequencerResets: metrics.NewEvent(factory, ns, "", "sequencer_resets", "sequencer resets"),
......@@ -449,6 +457,14 @@ func (m *Metrics) RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next
m.UnsafePayloadsBufferMemSize.Set(float64(memSize))
}
func (m *Metrics) RecordDerivedSingularBatches() {
m.DerivedSingularBatches.Record()
}
func (m *Metrics) RecordDerivedSpanBatches() {
m.DerivedSpanBatches.Record()
}
func (m *Metrics) CountSequencedTxs(count int) {
m.TransactionsSequencedTotal.Add(float64(count))
}
......@@ -646,6 +662,12 @@ func (n *noopMetricer) RecordL2Ref(name string, ref eth.L2BlockRef) {
func (n *noopMetricer) RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID) {
}
func (n *noopMetricer) RecordDerivedSingularBatches() {
}
func (n *noopMetricer) RecordDerivedSpanBatches() {
}
func (n *noopMetricer) CountSequencedTxs(count int) {
}
......
......@@ -97,6 +97,7 @@ func (cr *ChannelInReader) NextBatch(ctx context.Context) (Batch, error) {
return nil, NewCriticalError(errors.New("failed type assertion to SingularBatch"))
}
cr.log.Debug("decoded singular batch from channel")
cr.metrics.RecordDerivedSingularBatches()
return singularBatch, nil
case SpanBatchType:
if origin := cr.Origin(); !cr.cfg.IsDelta(origin.Time) {
......@@ -115,6 +116,7 @@ func (cr *ChannelInReader) NextBatch(ctx context.Context) (Batch, error) {
return nil, err
}
cr.log.Debug("decoded span batch from channel")
cr.metrics.RecordDerivedSpanBatches()
return spanBatch, nil
default:
// error is bubbled up to user, but pipeline can skip the batch and continue after.
......
......@@ -21,6 +21,8 @@ type Metrics interface {
RecordHeadChannelOpened()
RecordChannelTimedOut()
RecordFrame()
RecordDerivedSingularBatches()
RecordDerivedSpanBatches()
}
type L1Fetcher interface {
......
......@@ -27,6 +27,9 @@ type Metrics interface {
RecordChannelTimedOut()
RecordFrame()
RecordDerivedSingularBatches()
RecordDerivedSpanBatches()
RecordUnsafePayloadsBuffer(length uint64, memSize uint64, next eth.BlockID)
SetDerivationIdle(idle bool)
......
......@@ -53,6 +53,12 @@ func (t *TestDerivationMetrics) RecordChannelTimedOut() {
func (t *TestDerivationMetrics) RecordFrame() {
}
func (n *TestDerivationMetrics) RecordDerivedSingularBatches() {
}
func (n *TestDerivationMetrics) RecordDerivedSpanBatches() {
}
type TestRPCMetrics struct{}
func (n *TestRPCMetrics) RecordRPCServerRequest(method string) func() {
......
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