Skip to content

Commit

Permalink
Merge pull request #147 from ross/timed-context-self
Browse files Browse the repository at this point in the history
_TimedContextManagerDecorator enter -> self
  • Loading branch information
yannmh authored Aug 24, 2016
2 parents 393f804 + 188ee82 commit be01e58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions datadog/dogstatsd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def __enter__(self):
if not self.metric:
raise TypeError("Cannot used timed without a metric!")
self.start = time()
return self

def __exit__(self, type, value, traceback):
# Report the elapsed time of the context manager.
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/dogstatsd/test_statsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ def test_timed_context(self):
Measure the distribution of a context's run time.
"""
# In seconds
with self.statsd.timed('timed_context.test'):
with self.statsd.timed('timed_context.test') as timer:
t.assert_is_instance(timer, DogStatsd._TimedContextManagerDecorator)
time.sleep(0.5)

packet = self.recv()
Expand Down

0 comments on commit be01e58

Please sign in to comment.