Skip to content

Commit

Permalink
Use Counter type for channel_input_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Inphi committed Apr 7, 2023
1 parent c6a2717 commit 16c0815
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
6 changes: 3 additions & 3 deletions op-node/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ type Metrics struct {
GossipEventsTotal *prometheus.CounterVec
BandwidthTotal *prometheus.GaugeVec

ChannelInputBytes prometheus.Gauge
ChannelInputBytes prometheus.Counter

registry *prometheus.Registry
factory metrics.Factory
Expand Down Expand Up @@ -334,7 +334,7 @@ func NewMetrics(procName string) *Metrics {
"direction",
}),

ChannelInputBytes: factory.NewGauge(prometheus.GaugeOpts{
ChannelInputBytes: factory.NewCounter(prometheus.CounterOpts{
Namespace: ns,
Name: "channel_input_bytes",
Help: "Number of compressed bytes added to the channel",
Expand Down Expand Up @@ -645,7 +645,7 @@ func (m *Metrics) PayloadsQuarantineSize(n int) {
}

func (m *Metrics) RecordChannelInputBytes(inputCompressedBytes int) {
m.ChannelInputBytes.Set(float64(inputCompressedBytes))
m.ChannelInputBytes.Add(float64(inputCompressedBytes))
}

type noopMetricer struct{}
Expand Down
5 changes: 1 addition & 4 deletions op-node/rollup/derive/channel_in_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ type ChannelInReader struct {
prev *ChannelBank

metrics Metrics
// total amount of compressed bytes added to the channel
comprInputBytes int
}

var _ ResetableStage = (*ChannelInReader)(nil)
Expand All @@ -46,8 +44,7 @@ func (cr *ChannelInReader) Origin() eth.L1BlockRef {
func (cr *ChannelInReader) WriteChannel(data []byte) error {
if f, err := BatchReader(bytes.NewBuffer(data), cr.Origin()); err == nil {
cr.nextBatchFn = f
cr.comprInputBytes += len(data)
cr.metrics.RecordChannelInputBytes(cr.comprInputBytes)
cr.metrics.RecordChannelInputBytes(len(data))
return nil
} else {
cr.log.Error("Error creating batch reader from channel data", "err", err)
Expand Down

0 comments on commit 16c0815

Please sign in to comment.