Skip to content

Commit

Permalink
= newrelic: protect (again) against missing mixin of TraceContextAwar…
Browse files Browse the repository at this point in the history
…e in error events, related to #29
  • Loading branch information
ivantopo committed Dec 9, 2014
1 parent 4c040a5 commit 802bdd4
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down

0 comments on commit 802bdd4

Please sign in to comment.