All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gilt.newrelic.akka.TracingReceive.scala Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package com.gilt.newrelic.akka

import com.newrelic.api.agent.NewRelic
import com.newrelic.api.agent.Trace

import akka.actor.Actor.Receive

/**
 * Usage:
 * def receive = TracingReceive(name) {
 *   case msg: Msg => msg
 * }
 */
object TracingReceive {
  def apply(name: String)(r: Receive) = new TracingReceive(name, r)
}

class TracingReceive(name: String, r: Receive) extends Receive {
  override def isDefinedAt(a: Any) = r.isDefinedAt(a)

  @Trace(
    dispatcher = true,
    excludeFromTransactionTrace = true // don't show this individual function, as it is just a wrapper
  )
  override def apply(a: Any) = {
    NewRelic.setTransactionName("Akka", name)
    r.apply(a)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy