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

Retrieving an existing gauge, and possibly replacing it. #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

miracle2k
Copy link

This is currently based on #38, but that needn't be the case.

There are a couple elements here.

First, there is a bug in the existing code. Calling Metrology.gauge('name', my_gauge_instance) twice fails the second time, because the isinstance call here (https://github.com/cyberdelia/metrology/blob/master/metrology/registry.py#L70) will be called with my_gauge_instance instead of a class object, which fails.

I also run into the case of having a gauge that measures the length of a queue object, and the queue object will be replaced during the lifetime of the program, which means the gauge itself has to be replaced as well (it is not feasible in my case to implement a gauge subclass that can be pointed to a different queue).

Since:

  1. The gauge api requires a custom gauge instance to be passed Metrology.gauge('foo', gauge_instance)

  2. Two calls to these line of code currently return an error.

  3. The proper behaviour of

    Metrology.gauge('foo', gauge_instance1) Metrology.gauge('foo', gauge_instance2)

    not currently beging defined, it made sense to me to implement it such that the latter call will replace the metric in the registry.

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.

1 participant