Adam Babik 6da469140f
Refactor in-app metrics (#963)
Remove Prometheus and other metric types and use metrics package from go-ethereum.
2018-05-16 17:36:59 +02:00

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))
}