Skip to content

Commit

Permalink
= newrelic: fix ClassCastException in NewRelicErrorLogger
Browse files Browse the repository at this point in the history
when not using aspectJ weaver, fixes kamon-io#29
  • Loading branch information
adelio committed Apr 30, 2014
1 parent 0952d2b commit 53b71ee
Showing 1 changed file with 14 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,17 @@ 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 javaagent JVM startup parameter in" +
" your application. Please refer to http://kamon.io/get-started/ for instructions on how to do it.")
aspectJMissingAlreadyReported = true
}

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

0 comments on commit 53b71ee

Please sign in to comment.