diff options
author | Diego <diegolparra@gmail.com> | 2014-11-30 17:24:37 -0300 |
---|---|---|
committer | Diego <diegolparra@gmail.com> | 2014-11-30 17:24:37 -0300 |
commit | 433bd42c21c04a8c9af2400eadabd82e6a524c12 (patch) | |
tree | 58e7bba6507d6935283e68e8eaebc42e296b93a8 /kamon-newrelic/src/main/scala/kamon | |
parent | d87efc71d82220a4d6f5dba50a7424a5360ea63b (diff) | |
download | Kamon-433bd42c21c04a8c9af2400eadabd82e6a524c12.tar.gz Kamon-433bd42c21c04a8c9af2400eadabd82e6a524c12.tar.bz2 Kamon-433bd42c21c04a8c9af2400eadabd82e6a524c12.zip |
+ play, spray, newrelic: store in TraceLocal useful data to diagnose errors and closes #6
Diffstat (limited to 'kamon-newrelic/src/main/scala/kamon')
-rw-r--r-- | kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala index 08fdc8c4..d6920ad2 100644 --- a/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala +++ b/kamon-newrelic/src/main/scala/kamon/newrelic/NewRelicErrorLogger.scala @@ -21,7 +21,8 @@ import java.util import akka.actor.{ Actor, ActorLogging } import akka.event.Logging.{ Error, InitializeLogger, LoggerInitialized } import com.newrelic.api.agent.{ NewRelic ⇒ NR } -import kamon.trace.{ TraceRecorder, TraceContextAware } +import kamon.trace.TraceLocal.{ HttpContext, HttpContextKey } +import kamon.trace.{ TraceLocal, TraceRecorder, TraceContextAware } trait CustomParamsSupport { this: NewRelicErrorLogger ⇒ @@ -41,8 +42,16 @@ 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) + + 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) } if (error.cause == Error.NoCause) NR.noticeError(error.message.toString, params) |