[#176] Add New Relic appender (@polymeris)

This commit is contained in:
Camilo Polymeris 2016-07-02 15:42:23 -04:00 committed by Peter Taoussanis
parent 7ee42f71e7
commit 9cf8dec29c
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
(ns taoensso.timbre.appenders.3rd-party.appenders.newrelic
"A New Relic appender"
{:author "Camilo Polymeris"}
(:import (com.newrelic.api.agent NewRelic)
(java.util HashMap)))
(defn newrelic-appender
"New Relic appender. The Java agent must be installed and configured via newrelic.yml, see
https://docs.newrelic.com/docs/agents/java-agent/installation/java-agent-manual-installation#h2-install-agent"
[& _]
{:enabled? true
:async? true
:min-level :warn
:rate-limit [[100 60000]] ;matches New Relic's own cap
:output-fn :inherit
:fn (fn [data]
(let [{:keys [output-fn ?err level]} data
params (HashMap. {"Log level" (name level)})]
(if ?err
(NewRelic/noticeError ?err params)
(NewRelic/noticeError (output-fn data) params))))})