Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated statsd client to allow less than 1 ms timing #63

Closed
wants to merge 2 commits into from
Closed

Updated statsd client to allow less than 1 ms timing #63

wants to merge 2 commits into from

Conversation

scbunn
Copy link
Contributor

@scbunn scbunn commented Jun 23, 2015

Currently working on a project that requires the timing of functions that take less than 1 ms to run. Updated to allow for floating point values so timings of less than 1 ms can be represented.

@@ -82,7 +82,7 @@ def timer(self, stat, rate=1):

def timing(self, stat, delta, rate=1):
"""Send new timing information. `delta` is in milliseconds."""
self._send_stat(stat, '%d|ms' % delta, rate)
self._send_stat(stat, '%f|ms' % delta, rate)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be worth being more specific about the format here, to make the output more predictable, especially in the tests?

('gauge', 'g'),
('incr', 'c'),
('timing', 'ms'),
('gauge', 'g', 'foo:1234568901234|%s'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well just drop the suffix part and make the result the complete thing (along with adjusting the _check method to skip the result % suffix line, which is the only place suffix gets used.

@jsocol
Copy link
Owner

jsocol commented Jun 24, 2015

Made a couple of comments. Would you mind hitting those, adding a line to the changelog under 3.2, and squashing it all into one commit? Thanks!

@scbunn
Copy link
Contributor Author

scbunn commented Jun 26, 2015

@jsocol Awesome. I wanted to get to this yesterday, but ran out of time. I will get the updates made. How do you prefer squashing commits?

@jsocol
Copy link
Owner

jsocol commented Jun 26, 2015

@scbunn All squashed down into one commit, so code and tests changes are together, is perfect. Thanks so much!

@@ -50,7 +50,7 @@ def stop(self, send=True):
if self._start_time is None:
raise RuntimeError('Timer has not started.')
dt = time.time() - self._start_time
self.ms = int(round(1000 * dt)) # Convert to milliseconds.
self.ms = float(1000 * dt) # Convert to milliseconds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@scbunn The float() call is not necessary, dt is already a float and 1000 * dt will be a float too.

@jstasiak
Copy link
Contributor

This would be useful to have, I'm happy to apply the required changes so that this can be merged.

@scbunn
Copy link
Contributor Author

scbunn commented Aug 17, 2015

@jstasiak cool. I have been wanted to get back to this but have been too busy with other work projects. If you could wrap this up it would be appreciated.

@jstasiak
Copy link
Contributor

jstasiak commented Sep 1, 2015

@scbunn @jsocol Please see smarkets@a001224 (feature/allow_float_timings branch in https://github.com/smarkets/pystatsd)

One thing I left unchanged is the %f format as I don't know what to restrict it to and we can easily change it later.

@scbunn
Copy link
Contributor Author

scbunn commented Sep 1, 2015

@jstasiak your branch looks good to me. As far as %f formatter I would think that not limiting it would be best. Its possible that somebody might be timing something that needs a very high precision.

@jstasiak
Copy link
Contributor

@jsocol Is there a chance this is merged soon? Thanks in advance.

@jstasiak
Copy link
Contributor

jstasiak commented Oct 6, 2015

@jsocol I'm sorry if I'm being annoying, is there anything I can to get this merged? (and, ideally, released on PyPI, we have to use some custom code before 9bb4e99 is released)

@jsocol
Copy link
Owner

jsocol commented Oct 6, 2015

@jstasiak Can you open a PR from the smarkets branch? Thanks for addressing the comments there. The only thing I'd ask is if we can specify the decimals on the float formatter, something like 4 or 6 decimal points, because I don't know that that behavior is guaranteed not to change on a given platform or Python version.

@jstasiak
Copy link
Contributor

@jsocol I just created #66. I can't really spent much time on this right now but feel free to change the float formatting as needed (6 decimal places sounds reasonable).

@jsocol
Copy link
Owner

jsocol commented Oct 16, 2015

Thanks @jstasiak, closing this in favor of #66.

@jsocol jsocol closed this Oct 16, 2015
csestelo pushed a commit to Destygo/pystatsd that referenced this pull request Jul 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants