OLD | NEW |
---|---|
1 package metrics2 | 1 package metrics2 |
2 | 2 |
3 import "sync" | 3 import "sync" |
4 | 4 |
5 const ( | 5 const ( |
6 MEASUREMENT_COUNTER = "counter" | 6 MEASUREMENT_COUNTER = "counter" |
7 ) | 7 ) |
8 | 8 |
9 // Counter is a struct used for tracking metrics which increment or decrement. | 9 // Counter is a struct used for tracking metrics which increment or decrement. |
10 type Counter struct { | 10 type Counter struct { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 defer c.mtx.Unlock() | 44 defer c.mtx.Unlock() |
45 c.m.Update(c.m.Get() - i) | 45 c.m.Update(c.m.Get() - i) |
46 } | 46 } |
47 | 47 |
48 // Reset sets the counter to zero. | 48 // Reset sets the counter to zero. |
49 func (c *Counter) Reset() { | 49 func (c *Counter) Reset() { |
50 c.mtx.Lock() | 50 c.mtx.Lock() |
51 defer c.mtx.Unlock() | 51 defer c.mtx.Unlock() |
52 c.m.Update(0) | 52 c.m.Update(0) |
53 } | 53 } |
54 | |
55 // Count returns the current value in the counter. | |
56 func (c *Counter) Count() int64 { | |
borenet
2016/02/10 15:32:32
For consistency, let's just call this Get()
kjlubick
2016/02/10 16:14:29
Done.
| |
57 c.mtx.Lock() | |
58 defer c.mtx.Unlock() | |
59 return c.m.Get() | |
60 } | |
OLD | NEW |