metrics.go 782 B

1234567891011121314151617181920212223242526272829
  1. // Go port of Coda Hale's Metrics library
  2. //
  3. // <https://github.com/rcrowley/go-metrics>
  4. //
  5. // Coda Hale's original work: <https://github.com/codahale/metrics>
  6. package metrics
  7. // UseNilMetrics is checked by the constructor functions for all of the
  8. // standard metrics. If it is true, the metric returned is a stub.
  9. //
  10. // This global kill-switch helps quantify the observer effect and makes
  11. // for less cluttered pprof profiles.
  12. var UseNilMetrics bool = false
  13. type metric struct {
  14. name string
  15. m interface{}
  16. }
  17. // metrics is a slice of metrics that implements sort.Interface
  18. type metrics []metric
  19. func (m metrics) Len() int { return len(m) }
  20. func (m metrics) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
  21. func (m metrics) Less(i, j int) bool {
  22. return m[i].name < m[j].name
  23. }