Skip to content

Commit

Permalink
Fix for ClassCastException when using NewRelicErrorLogger whithout as…
Browse files Browse the repository at this point in the history
…pecj weaver (kamon-io#29)
  • Loading branch information
adelio committed Apr 29, 2014
1 parent 0952d2b commit ac18e8b
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
* ========================================================== */
package kamon.newrelic

import akka.actor.Actor
import akka.actor.{ActorLogging, Actor}
import akka.event.Logging.Error
import akka.event.Logging.{ LoggerInitialized, InitializeLogger }
import com.newrelic.api.agent.{ NewRelic NR }
import kamon.trace.TraceContextAware

class NewRelicErrorLogger extends Actor {
class NewRelicErrorLogger extends Actor with ActorLogging {
var aspectJMissingAlreadyReported = false

def receive = {
case InitializeLogger(_) sender ! LoggerInitialized
case error @ Error(cause, logSource, logClass, message) notifyError(error)
Expand All @@ -30,10 +32,16 @@ class NewRelicErrorLogger extends Actor {

def notifyError(error: Error): Unit = {
val params = new java.util.HashMap[String, String]()
val ctx = error.asInstanceOf[TraceContextAware].traceContext

for (c ctx) {
params.put("TraceToken", c.token)
if (error.isInstanceOf[TraceContextAware]) {
val ctx = error.asInstanceOf[TraceContextAware].traceContext

for (c ctx) {
params.put("TraceToken", c.token)
}
} else if (! aspectJMissingAlreadyReported) {
log.warning("ASPECTJ WEAVER MISSING. You might have missed to include the java agent")
aspectJMissingAlreadyReported = true
}

if (error.cause == Error.NoCause) {
Expand Down

0 comments on commit ac18e8b

Please sign in to comment.