Merge "stats: Round timings at 4 decimal places"
This commit is contained in:
commit
2b45eb1c55
@ -1499,7 +1499,7 @@ class StatsdClient(object):
|
|||||||
|
|
||||||
def _timing(self, metric, timing_ms, sample_rate):
|
def _timing(self, metric, timing_ms, sample_rate):
|
||||||
# This method was added to disagregate timing metrics when testing
|
# This method was added to disagregate timing metrics when testing
|
||||||
return self._send(metric, timing_ms, 'ms', sample_rate)
|
return self._send(metric, round(timing_ms, 4), 'ms', sample_rate)
|
||||||
|
|
||||||
def timing(self, metric, timing_ms, sample_rate=None):
|
def timing(self, metric, timing_ms, sample_rate=None):
|
||||||
return self._timing(metric, timing_ms, sample_rate)
|
return self._timing(metric, timing_ms, sample_rate)
|
||||||
|
@ -5516,6 +5516,10 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
|||||||
self.assertStat('pfx.some.operation:4900.0|ms|@0.972',
|
self.assertStat('pfx.some.operation:4900.0|ms|@0.972',
|
||||||
self.logger.timing, 'some.operation', 4.9 * 1000,
|
self.logger.timing, 'some.operation', 4.9 * 1000,
|
||||||
sample_rate=0.972)
|
sample_rate=0.972)
|
||||||
|
self.assertStat(
|
||||||
|
'pfx.some.hi-res.operation:3141.5927|ms|@0.367879441171',
|
||||||
|
self.logger.timing, 'some.hi-res.operation',
|
||||||
|
3.141592653589793 * 1000, sample_rate=0.367879441171)
|
||||||
self.assertStatMatches(r'pfx\.another\.op:\d+\.\d+\|ms|@0.972',
|
self.assertStatMatches(r'pfx\.another\.op:\d+\.\d+\|ms|@0.972',
|
||||||
self.logger.timing_since, 'another.op',
|
self.logger.timing_since, 'another.op',
|
||||||
time.time(), sample_rate=0.972)
|
time.time(), sample_rate=0.972)
|
||||||
|
Loading…
Reference in New Issue
Block a user