-
Notifications
You must be signed in to change notification settings - Fork 32
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
Reload/refresh and using the default prometheus registry to instrument functions #11
Comments
Iapetos registries are "immutable" (not really, though, due to the underlying mutable Prometheus registry), so while So, basically, the REPL session you pasted should always throw an exception, but if you replaced (defonce registry
(-> prometheus/default-registry
(fn/initialize)))
(fn/instrument! registry #'my-fun-1)
(my-fun-1)
;; => "EHLO" Hope I didn't misunderstand your question and this helps! |
Ok, thanks. Still, I think (will verify) I get the same error using my "wrapped" registry - at least after a round of refresh/reload etc. The reason I posted is that it all seems to work fine in production/test where we only instantiate these things once but provides a terrible development experience when we constantly reload the namepaces and do bootstrapping all over again. |
Hi, I verified that the issue still stands. What I found is that (as I suspected) initially everything works as expected. After a refresh the instrumentation stops working. Here is another repl-session:
Does that make anything clearer? |
I tried it out, replicating your REPL session and what happens is that (let [registry iapetos.registry/default]
(try
(-> registry
(fn/initialize))
(catch IllegalArgumentException e
registry))) Now, So, this is indeed a problem (and something I didn't think of when I introduced the default registry). One thing that could solve this is implementing |
Aha, thank you for investigating further! Sounds more or less like what I was expecting although expressed with insight into the actual implementation. |
I realized that perhaps I can get by by simply using the |
Something like this seems to work:
|
Hi,
I am having a little trouble using the default registry and instrumenting functions with it. At first I thought it was solely due to the fact that I use component and refresh/reload of all namespaces a lot so i
defonce
:ed the definition of the registry and made sure to dofn/initialize
only once.Like so:
Still, this is what happens when I try to call an instrumented function
I have checked that the
fn_...
metrics are registered in the export from the default registry, but I cannot seem to get instrumentation to work. Somehow it seems that I am caught between some protocol redefinition or cached reference in iapetos and what the Prometheus default registry thinks is already registered.The above code works fine in a fresh project, void of any dependencies or code except for iapetos itself.
How would you suggest I go about using the default registry?
I would prefer not having to use it, but most other integrations (like, for example the logback appender) insist on using Prometheus
CollectorRegistry/defaultRegistry
.The text was updated successfully, but these errors were encountered: