You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
747 B

6 years ago
6 years ago
  1. package p2p
  2. import (
  3. "github.com/go-kit/kit/metrics"
  4. "github.com/go-kit/kit/metrics/discard"
  5. prometheus "github.com/go-kit/kit/metrics/prometheus"
  6. stdprometheus "github.com/prometheus/client_golang/prometheus"
  7. )
  8. // Metrics contains metrics exposed by this package.
  9. type Metrics struct {
  10. // Number of peers.
  11. Peers metrics.Gauge
  12. }
  13. // PrometheusMetrics returns Metrics build using Prometheus client library.
  14. func PrometheusMetrics() *Metrics {
  15. return &Metrics{
  16. Peers: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
  17. Subsystem: "p2p",
  18. Name: "peers",
  19. Help: "Number of peers.",
  20. }, []string{}),
  21. }
  22. }
  23. // NopMetrics returns no-op Metrics.
  24. func NopMetrics() *Metrics {
  25. return &Metrics{
  26. Peers: discard.NewGauge(),
  27. }
  28. }