Skip to content

Instantly share code, notes, and snippets.

@barkanido
Created January 23, 2019 04:36
Show Gist options
  • Save barkanido/8d9a60c142692ac63019e1d6293c528c to your computer and use it in GitHub Desktop.
Save barkanido/8d9a60c142692ac63019e1d6293c528c to your computer and use it in GitHub Desktop.
(ns af-common-rta-aerospike.core
(:require [aerospike-clj.client :as aero]
[statsd.metrics :as metrics]
[statsd.core :as statsd]
[manifold.deferred :as d]))
(defrecord DBMeter []
client/ClientEvents
(on-success [_ op-name op-result _index op-start-time client]
(statsd/send-timing (metrics/format-statsd-metric (:cluster-name client) op-name "latency")
(micros-from op-start-time)
STATSD-RATE)
(statsd/inc-metric (metrics/format-statsd-metric (:cluster-name client) op-name "success"))
(when (= "read" op-name)
(if (some? op-result)
(statsd/inc-metric (metrics/format-statsd-metric (:cluster-name client) "read" "hit"))
(statsd/inc-metric (metrics/format-statsd-metric (:cluster-name client) "read" "miss"))))
op-result)
(on-failure [_ op-name op-ex index op-start-time client]
(statsd/send-timing (metrics/format-statsd-metric (:cluster-name client) op-name "latency")
(micros-from op-start-time)
STATSD-RATE)
(statsd/inc-metric (metrics/format-statsd-metric-fail-aerospike op-ex (:cluster-name client) op-name))
(d/error-deferred op-ex)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment