models.go 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package metrics
  2. import (
  3. "leafstalk/conf"
  4. )
  5. // Summary defines a summary metric
  6. type Summary struct {
  7. Subsystem string
  8. Name string
  9. Help string
  10. Objectives map[float64]float64
  11. Labels []string
  12. }
  13. // Gauge defines a gauge metric
  14. type Gauge struct {
  15. Subsystem string
  16. Name string
  17. Help string
  18. Labels []string
  19. }
  20. // Counter defines a counter metric
  21. type Counter struct {
  22. Subsystem string
  23. Name string
  24. Help string
  25. Labels []string
  26. }
  27. // CustomMetricsSpec has all metrics specs
  28. type CustomMetricsSpec struct {
  29. Summaries []*Summary
  30. Gauges []*Gauge
  31. Counters []*Counter
  32. }
  33. //NewCustomMetricsSpec returns a *CustomMetricsSpec by reading config key
  34. func NewCustomMetricsSpec(config *conf.Config) (*CustomMetricsSpec, error) {
  35. var spec CustomMetricsSpec
  36. err := config.UnmarshalKey("grave.metrics.custom", &spec)
  37. if err != nil {
  38. return nil, err
  39. }
  40. return &spec, nil
  41. }