Liking cljdoc? Tell your friends :D

cache-metrics.core

Dropwizard Metrics instrumentation for core.cache caches.

Usage

To count the cache hits and the misses, wrap the cache in instrumented-cache-factory.

(def my-registry (MetricsRegistry.))

(defn create-cache []
  (-> (lru-cache-factory {})
      (instrumented-cache-factory :registry my-registry)))

If you follow the usage pattern recommend by core.cache documentation and wrap the cache in an atom, you can measure the cache size with cache-size-gauge.

(def my-cache-a (atom (create-cache)))
(.register my-registry "clojure.core.cache.size" (cache-size-gauge my-cache-a))
Dropwizard Metrics instrumentation for core.cache caches.

## Usage

To count the cache hits and the misses, wrap the cache in
[[instrumented-cache-factory]].

    (def my-registry (MetricsRegistry.))

    (defn create-cache []
      (-> (lru-cache-factory {})
          (instrumented-cache-factory :registry my-registry)))

If you follow the usage pattern recommend by core.cache documentation and wrap
the cache in an atom, you can measure the cache size with
[[cache-size-gauge]].

    (def my-cache-a (atom (create-cache)))
    (.register my-registry "clojure.core.cache.size" (cache-size-gauge my-cache-a))
raw docstring

cache-size-gaugeclj

(cache-size-gauge cache-a)
source

instrumented-cache-factoryclj

(instrumented-cache-factory base
                            &
                            {:keys [registry metric-name]
                             :or {metric-name "clojure.core.cache"}})

Wrap base cache with instrumentation logic that counts the hits and the misses.

Expects :registry argument that is the MetricRegistry for the metrics. Optionally :metric-name argument specifies the name prefix for the metircs.

Wrap base cache with instrumentation logic that counts the hits and the
misses.

Expects `:registry` argument that is the MetricRegistry for the metrics.
Optionally `:metric-name` argument specifies the name prefix for the metircs.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close