mirror of
https://github.com/status-im/status-go.git
synced 2025-01-09 06:12:55 +00:00
6da469140f
Remove Prometheus and other metric types and use metrics package from go-ethereum.
26 lines
750 B
Go
26 lines
750 B
Go
// Package whisper collects Whisper envelope metrics using expvar.
|
|
package whisper
|
|
|
|
import (
|
|
"github.com/ethereum/go-ethereum/metrics"
|
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
|
)
|
|
|
|
var (
|
|
envelopeCounter = metrics.NewRegisteredCounter("whisper/Envelope", nil)
|
|
envelopeNewCounter = metrics.NewRegisteredCounter("whisper/EnvelopeNew", nil)
|
|
envelopeMeter = metrics.NewRegisteredMeter("whisper/EnvelopeSize", nil)
|
|
)
|
|
|
|
// EnvelopeTracer traces incoming envelopes.
|
|
type EnvelopeTracer struct{}
|
|
|
|
// Trace is called for every incoming envelope.
|
|
func (t *EnvelopeTracer) Trace(envelope *whisper.EnvelopeMeta) {
|
|
envelopeCounter.Inc(1)
|
|
if envelope.IsNew {
|
|
envelopeNewCounter.Inc(1)
|
|
}
|
|
envelopeMeter.Mark(int64(envelope.Size))
|
|
}
|