diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-12-09 14:36:55 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-12-09 14:36:55 +0100 |
commit | ebfced13639db17ad4348fefb2805b5d234ee178 (patch) | |
tree | 150e729ac0d91b0c16e1369b9684224a77724de8 /kamon-newrelic/src/main/scala | |
parent | ef092468f819597f44370c8870ae3b4a26529ef4 (diff) | |
download | Kamon-ebfced13639db17ad4348fefb2805b5d234ee178.tar.gz Kamon-ebfced13639db17ad4348fefb2805b5d234ee178.tar.bz2 Kamon-ebfced13639db17ad4348fefb2805b5d234ee178.zip |
= newrelic: protect (again) against missing mixin of TraceContextAware in error events, related to #29
Diffstat (limited to 'kamon-newrelic/src/main/scala')
-rw-r--r-- | kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala index d6920ad2..9c4b90d3 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala @@ -41,15 +41,18 @@ class NewRelicErrorLogger extends Actor with ActorLogging with CustomParamsSuppo def notifyError(error: Error): Unit = runInFakeTransaction { val params = new util.HashMap[String, String]() - val ctx = error.asInstanceOf[TraceContextAware].traceContext - val httpContext = TraceLocal.retrieve(HttpContextKey) - params put ("TraceToken", ctx.token) + if(error.isInstanceOf[TraceContextAware]) { + val ctx = error.asInstanceOf[TraceContextAware].traceContext + val httpContext = TraceLocal.retrieve(HttpContextKey) - httpContext.map { httpCtx ⇒ - params put ("User-Agent", httpCtx.agent) - params put ("X-Forwarded-For", httpCtx.xforwarded) - params put ("Request-URI", httpCtx.uri) + params put ("TraceToken", ctx.token) + + httpContext.map { httpCtx ⇒ + params put ("User-Agent", httpCtx.agent) + params put ("X-Forwarded-For", httpCtx.xforwarded) + params put ("Request-URI", httpCtx.uri) + } } customParams foreach { case (k, v) ⇒ params.put(k, v) } |