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

Make io.prometheus.client.CollectorRegistry.defaultRegistry usable together with iapetos #10

Closed
delitescere opened this issue Sep 10, 2017 · 4 comments

Comments

@delitescere
Copy link

delitescere commented Sep 10, 2017

G'day! This is an awesome library. Thank you so much for making it.

I'm enjoying the ring and jvm wrappers very much. However, I've recently added to my project the InstrumentedAppender but it only has a mechanism for registering its collector with the Prometheus Java client's default registry.

This means that the ring wrapper exposing metrics at /metrics doesn't pick up any non-iapetos collectors because a different default registry is created by iapetos.

I'm wondering if https://github.com/xsc/iapetos/blob/master/src/iapetos/registry.clj#L79 should be more like:

(defn create
  ([]
   (IapetosRegistry. "iapetos_registry" (CollectorRegistry/defaultRegistry) {} {})))
  ([registry-name]
   (IapetosRegistry. registry-name (CollectorRegistry.) {} {})))

This keeps the "iapetos_registry" name for the default registry for any existing code that might use it, but uses the underlying Prometheus Java client's default registry.

@delitescere delitescere changed the title Use io.prometheus.client.CollectorRegistry.defaultRegistry by default? Use io.prometheus.client.CollectorRegistry.defaultRegistry by default? Sep 10, 2017
@xsc
Copy link
Collaborator

xsc commented Sep 14, 2017

@delitescere Thanks for reaching out! I do have a problem, though, with implicitly exposing the default registry, since create kinda indicates that a fresh registry is produced. What do you think about just adding iapetos.core/default-registry? Then anyone could decide to use it directly and explicitly.

Note to self: pushable-collector-registry needs an adjustment for this, allowing a registry to be injected.

@xsc xsc added the question label Sep 14, 2017
@delitescere
Copy link
Author

@xsc excellent idea.

@xsc xsc added enhancement and removed question labels Sep 18, 2017
@xsc xsc changed the title Use io.prometheus.client.CollectorRegistry.defaultRegistry by default? Make io.prometheus.client.CollectorRegistry.defaultRegistry usable together with iapetos? Sep 18, 2017
@xsc xsc changed the title Make io.prometheus.client.CollectorRegistry.defaultRegistry usable together with iapetos? Make io.prometheus.client.CollectorRegistry.defaultRegistry usable together with iapetos Sep 18, 2017
@xsc xsc closed this as completed in d6de161 Sep 18, 2017
@xsc
Copy link
Collaborator

xsc commented Sep 18, 2017

Release Notes

@delitescere
Copy link
Author

delitescere commented Sep 23, 2017

Yes, the problem is now there's no surface idempotency. I'm using this in a stuartsierra system, so components can be started, stopped, and restarted. As the same registry is being used, the collectors have already been registered. There's no iapetos mechanism for unregistering at the moment.

Given I'm using the Prometheus default registry, I can add the following to the "stop" lifecycle task of the component:

(.clear CollectorRegistry/defaultRegistry)

This is a little heavy-handed as any collectors my Clojure app doesn't register as part of the "start" lifecycle will be unregistered and not return (although this is not likely in my case). Perhaps the IapetosRegistry protocol could forward the clear and unregister methods to the underlying Prometheus registry?

On sum, though, I'm perfectly happy with things as they are. Many thanks!

xsc pushed a commit that referenced this issue Nov 6, 2017
These will only work on collectors that were actually registered with
a given registry instance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants