Skip to content
This repository has been archived by the owner on Mar 28, 2021. It is now read-only.

Expose a context manager for histograms #5

Merged
merged 3 commits into from
Jun 24, 2015

Conversation

roncohen
Copy link
Contributor

@roncohen roncohen commented Mar 2, 2015

  • Makes it a lot easier to use AppMetrics to time specific parts of the code
  • Modifies the documentation a little, to make it clear that with_histogram will in fact "time" your code when used in a decorator.

- Makes it a lot easier to use AppMetrics to time specific parts of the code
- Modifies the documentation a little, to make it clear that `with_histogram` will in fact "time" your code when used in a decorator.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 99.23% when pulling 0cca2e6 on roncohen:feature/contextmanager into a7ebbbe on avalente:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 99.28% when pulling 5dd1925 on roncohen:feature/contextmanager into a7ebbbe on avalente:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 99.28% when pulling 5dd1925 on roncohen:feature/contextmanager into a7ebbbe on avalente:master.

@avalente
Copy link
Owner

avalente commented Mar 3, 2015

Hi,
I wouldn't pollute Histogram's interface, I'd rather use a function similar to with_histogram, probably with the same signature and semantic, something such as:

@contextmanager
def timer(name, reservoir_type="uniform", *reservoir_args, **reservoir_kwargs):
    # ... same stuff as with_historgram ...

    t1 = time.time()
    yield
    t2 = time.time()
    hmetric.notify(t2-t1)


it seems more clear to me, what do you think?

@roncohen
Copy link
Contributor Author

roncohen commented Mar 3, 2015

I'm not a fan of the "with_histogram" interface that's why I put in on the Histogram. Of course, its up to you. I'll refactor.

@avalente
Copy link
Owner

avalente commented Mar 5, 2015

Thank you. I prefer to keep the interfaces coherent as much as possible and push specificities out of the classes.

@avalente avalente merged commit 5dd1925 into avalente:master Jun 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants