Skip to content

Instantly share code, notes, and snippets.

@ivos
Last active May 2, 2020 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivos/23a6cd5149bc4bc4dc86872e2f8cedbd to your computer and use it in GitHub Desktop.
Save ivos/23a6cd5149bc4bc4dc86872e2f8cedbd to your computer and use it in GitHub Desktop.
(ns backend.support.aspects
(:require ...
[backend.support.java-melody :as melody]))
(defn- monitoring-hook
[f & args]
(let [ns-name (->ns-name f)
fn-name (->fn-name f)
melody-request-name (str ns-name "/" fn-name)]
(.bindContextIncludingCpu melody/ejb-counter melody-request-name)
(try
(let [result (apply f args)]
(.addRequestForCurrentContext melody/ejb-counter false)
result)
(catch Throwable t
(.addRequestForCurrentContext melody/ejb-counter true)
(throw t)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment