Skip to content

Reload/refresh and using the default prometheus registry to instrument functions #11

Open
@codification

Description

@codification

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 do fn/initialize only once.

Like so:

(defonce registry (let [registry iapetos.registry/default]
                    (try
                      (-> registry
                          (fn/initialize))
                      (catch IllegalArgumentException e
                        registry))))

Still, this is what happens when I try to call an instrumented function

user> (require '[iapetos.core :as prometheus]
               '[iapetos.collector.fn :as fn])
nil
user> (defn my-fun-1 [] "EHLO")
#'user/my-fun-1
user> (fn/instrument! prometheus/default-registry #'my-fun-1)
#object[iapetos.registry.IapetosRegistry 0x78aa7886 "iapetos.registry.IapetosRegistry@78aa7886"]
user> (my-fun-1)
IllegalArgumentException No implementation of method: :increment* of protocol: #'iapetos.operations/IncrementableCollector found for class: nil  clojure.core/-cache-protocol-fn (core_deftype.clj:583)
user> 

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions