mirror of
https://github.com/status-im/status-go.git
synced 2025-01-19 03:04:54 +00:00
6cdea4ef97
* Update project to use Whisper v6. Part of #638 * Revert "Add patch to downgrade usage of Whisper v6 to v5 in some geth 1.8.1 vendor files. Part of #665" - this reverts commit 6aefb4c8fd02dbcfffac6b69e8bb22b13ef86b6b. * Enable light mode on Whisper v6 for non-mail servers. Part of #638 * Fix race condition in whisperv6/peer.go. Part of #665 (PR already accepted upstream for 1.8.2) * Update bootnode addresses in staticnodes.json. Part of #638 * Add `shh.lightclient` flag and tests for bloom filter setting logic. Part of #638 * Move MakeTestNodeConfig to utils. Part of #638 * Reduce PoW in `whisper_jail_test.go` to fix flaky test. Part of #638
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
// +build metrics,prometheus
|
|
|
|
// Package whisper collects Whisper envelope metrics using Prometheus.
|
|
package whisper
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
whisper "github.com/ethereum/go-ethereum/whisper/whisperv6"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
var (
|
|
envelopeCounter = prometheus.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "envelope_counter",
|
|
Help: "Envelopes counter",
|
|
},
|
|
[]string{"topic", "source", "is_new", "peer"},
|
|
)
|
|
envelopeVolume = prometheus.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "envelope_volume",
|
|
Help: "Volume of received envelopes",
|
|
},
|
|
[]string{"topic", "source", "is_new", "peer"},
|
|
)
|
|
)
|
|
|
|
func init() {
|
|
prometheus.MustRegister(envelopeCounter)
|
|
prometheus.MustRegister(envelopeVolume)
|
|
}
|
|
|
|
// EnvelopeTracer traces incoming envelopes.
|
|
type EnvelopeTracer struct{}
|
|
|
|
// Trace is called for every incoming envelope.
|
|
func (t *EnvelopeTracer) Trace(envelope *whisper.EnvelopeMeta) {
|
|
labelValues := []string{
|
|
envelope.Topic.String(),
|
|
envelope.SourceString(),
|
|
strconv.FormatBool(envelope.IsNew),
|
|
envelope.Peer,
|
|
}
|
|
|
|
envelopeCounter.WithLabelValues(labelValues...).Inc()
|
|
envelopeVolume.WithLabelValues(labelValues...).Add(float64(envelope.Size))
|
|
}
|