metric_ref.go 845 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package metrics
  2. type comboCounterRef struct {
  3. usageCounter Counter
  4. metricCounter Counter
  5. }
  6. func NewComboCounterRef(name string) Counter {
  7. cr := &comboCounterRef{}
  8. cr.usageCounter = UsageStats.GetOrRegister(name, NewCounter).(Counter)
  9. cr.metricCounter = MetricStats.GetOrRegister(name, NewCounter).(Counter)
  10. return cr
  11. }
  12. func (c comboCounterRef) Clear() {
  13. c.usageCounter.Clear()
  14. c.metricCounter.Clear()
  15. }
  16. func (c comboCounterRef) Count() int64 {
  17. panic("Count called on a combocounter ref")
  18. }
  19. // Dec panics.
  20. func (c comboCounterRef) Dec(i int64) {
  21. c.usageCounter.Dec(i)
  22. c.metricCounter.Dec(i)
  23. }
  24. // Inc panics.
  25. func (c comboCounterRef) Inc(i int64) {
  26. c.usageCounter.Inc(i)
  27. c.metricCounter.Inc(i)
  28. }
  29. // Snapshot returns the snapshot.
  30. func (c comboCounterRef) Snapshot() Counter {
  31. panic("snapshot called on a combocounter ref")
  32. }