Created
January 23, 2019 04:36
-
-
Save barkanido/8d9a60c142692ac63019e1d6293c528c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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