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
833 B

  1. package state
  2. import (
  3. "github.com/go-kit/kit/metrics"
  4. "github.com/go-kit/kit/metrics/discard"
  5. "github.com/go-kit/kit/metrics/prometheus"
  6. stdprometheus "github.com/prometheus/client_golang/prometheus"
  7. )
  8. const MetricsSubsystem = "state"
  9. type Metrics struct {
  10. // Time between BeginBlock and EndBlock.
  11. BlockProcessingTime metrics.Histogram
  12. }
  13. func PrometheusMetrics(namespace string) *Metrics {
  14. return &Metrics{
  15. BlockProcessingTime: prometheus.NewHistogramFrom(stdprometheus.HistogramOpts{
  16. Namespace: namespace,
  17. Subsystem: MetricsSubsystem,
  18. Name: "block_processing_time",
  19. Help: "Time between BeginBlock and EndBlock in ms.",
  20. Buckets: stdprometheus.LinearBuckets(1, 10, 10),
  21. }, []string{}),
  22. }
  23. }
  24. func NopMetrics() *Metrics {
  25. return &Metrics{
  26. BlockProcessingTime: discard.NewHistogram(),
  27. }
  28. }