This repository has been archived by the owner on Feb 24, 2023. It is now read-only.
forked from DataDog/datadogpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a timed context manager to statsd.
This enables a context manager in statsd so you can easily time a set of code without saving the start time, etc. manually: ```python with statsd.timed_context('user.query.time', sample_rate=0.5): # Do what you need to ... pass start = time.time() try: get_user(user_id) finally: statsd.timing('user.query.time', time.time() - start) ``` Two tests are also added for this code. Fixes DataDog#25
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters