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.

34 lines
837 B

7 years ago
7 years ago
  1. package mempool
  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. // see MetricsProvider for descriptions.
  10. type Metrics struct {
  11. // Size of the mempool.
  12. Size metrics.Gauge
  13. }
  14. // PrometheusMetrics returns Metrics build using Prometheus client library.
  15. func PrometheusMetrics() *Metrics {
  16. return &Metrics{
  17. Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
  18. Subsystem: "mempool",
  19. Name: "size",
  20. Help: "Size of the mempool (number of uncommitted transactions).",
  21. }, []string{}),
  22. }
  23. }
  24. // NopMetrics returns no-op Metrics.
  25. func NopMetrics() *Metrics {
  26. return &Metrics{
  27. Size: discard.NewGauge(),
  28. }
  29. }