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
877 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(namespace string) *Metrics {
  16. return &Metrics{
  17. Size: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
  18. Namespace: namespace,
  19. Subsystem: "mempool",
  20. Name: "size",
  21. Help: "Size of the mempool (number of uncommitted transactions).",
  22. }, []string{}),
  23. }
  24. }
  25. // NopMetrics returns no-op Metrics.
  26. func NopMetrics() *Metrics {
  27. return &Metrics{
  28. Size: discard.NewGauge(),
  29. }
  30. }