Commit 16c08152 authored by inphi's avatar inphi

Use Counter type for channel_input_bytes

parent c6a27170
...@@ -132,7 +132,7 @@ type Metrics struct { ...@@ -132,7 +132,7 @@ type Metrics struct {
GossipEventsTotal *prometheus.CounterVec GossipEventsTotal *prometheus.CounterVec
BandwidthTotal *prometheus.GaugeVec BandwidthTotal *prometheus.GaugeVec
ChannelInputBytes prometheus.Gauge ChannelInputBytes prometheus.Counter
registry *prometheus.Registry registry *prometheus.Registry
factory metrics.Factory factory metrics.Factory
...@@ -334,7 +334,7 @@ func NewMetrics(procName string) *Metrics { ...@@ -334,7 +334,7 @@ func NewMetrics(procName string) *Metrics {
"direction", "direction",
}), }),
ChannelInputBytes: factory.NewGauge(prometheus.GaugeOpts{ ChannelInputBytes: factory.NewCounter(prometheus.CounterOpts{
Namespace: ns, Namespace: ns,
Name: "channel_input_bytes", Name: "channel_input_bytes",
Help: "Number of compressed bytes added to the channel", Help: "Number of compressed bytes added to the channel",
...@@ -645,7 +645,7 @@ func (m *Metrics) PayloadsQuarantineSize(n int) { ...@@ -645,7 +645,7 @@ func (m *Metrics) PayloadsQuarantineSize(n int) {
} }
func (m *Metrics) RecordChannelInputBytes(inputCompressedBytes int) { func (m *Metrics) RecordChannelInputBytes(inputCompressedBytes int) {
m.ChannelInputBytes.Set(float64(inputCompressedBytes)) m.ChannelInputBytes.Add(float64(inputCompressedBytes))
} }
type noopMetricer struct{} type noopMetricer struct{}
......
...@@ -23,8 +23,6 @@ type ChannelInReader struct { ...@@ -23,8 +23,6 @@ type ChannelInReader struct {
prev *ChannelBank prev *ChannelBank
metrics Metrics metrics Metrics
// total amount of compressed bytes added to the channel
comprInputBytes int
} }
var _ ResetableStage = (*ChannelInReader)(nil) var _ ResetableStage = (*ChannelInReader)(nil)
...@@ -46,8 +44,7 @@ func (cr *ChannelInReader) Origin() eth.L1BlockRef { ...@@ -46,8 +44,7 @@ func (cr *ChannelInReader) Origin() eth.L1BlockRef {
func (cr *ChannelInReader) WriteChannel(data []byte) error { func (cr *ChannelInReader) WriteChannel(data []byte) error {
if f, err := BatchReader(bytes.NewBuffer(data), cr.Origin()); err == nil { if f, err := BatchReader(bytes.NewBuffer(data), cr.Origin()); err == nil {
cr.nextBatchFn = f cr.nextBatchFn = f
cr.comprInputBytes += len(data) cr.metrics.RecordChannelInputBytes(len(data))
cr.metrics.RecordChannelInputBytes(cr.comprInputBytes)
return nil return nil
} else { } else {
cr.log.Error("Error creating batch reader from channel data", "err", err) cr.log.Error("Error creating batch reader from channel data", "err", err)
......
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