All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
akka.monitor.instrumentation.RouterInstrumentation.scala Maven / Gradle / Ivy
/*
* =========================================================================================
* Copyright © 2017,2018 Workday, Inc.
* Copyright © 2013-2017 the kamon project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
* =========================================================================================
*/
package akka.monitor.instrumentation
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.{ After, Around, Aspect, DeclareMixin, Pointcut }
import akka.actor.{ ActorRef, ActorSystem, Cell, Props }
import akka.dispatch.{ Envelope, MessageDispatcher }
import akka.routing.RoutedActorCell
@Aspect
class RoutedActorCellInstrumentation {
def routerInstrumentation(cell: Cell): RouterMonitor =
cell.asInstanceOf[RouterInstrumentationAware].routerInstrumentation
@Pointcut("execution(akka.routing.RoutedActorCell.new(..)) && this(cell) && args(system, ref, props, dispatcher, routeeProps, supervisor)")
def routedActorCellCreation(cell: RoutedActorCell, system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, routeeProps: Props, supervisor: ActorRef): Unit = {}
@After("routedActorCellCreation(cell, system, ref, props, dispatcher, routeeProps, supervisor)")
def afterRoutedActorCellCreation(cell: RoutedActorCell, system: ActorSystem, ref: ActorRef, props: Props, dispatcher: MessageDispatcher, routeeProps: Props, supervisor: ActorRef): Unit = {
cell.asInstanceOf[RouterInstrumentationAware].setRouterInstrumentation(
RouterMonitor.createRouterInstrumentation(cell))
}
@Pointcut("execution(* akka.routing.RoutedActorCell.sendMessage(*)) && this(cell) && args(envelope)")
def sendMessageInRouterActorCell(cell: RoutedActorCell, envelope: Envelope) = {}
@Around("sendMessageInRouterActorCell(cell, envelope)")
def aroundSendMessageInRouterActorCell(pjp: ProceedingJoinPoint, cell: RoutedActorCell, envelope: Envelope): Any = {
routerInstrumentation(cell).processMessage(pjp)
}
}
trait RouterInstrumentationAware {
def routerInstrumentation: RouterMonitor
def setRouterInstrumentation(ai: RouterMonitor): Unit
}
object RouterInstrumentationAware {
def apply(): RouterInstrumentationAware = new RouterInstrumentationAware {
private var _ri: RouterMonitor = _
override def setRouterInstrumentation(ai: RouterMonitor): Unit = _ri = ai
override def routerInstrumentation: RouterMonitor = _ri
}
}
@Aspect
class MetricsIntoRouterCellsMixin {
@DeclareMixin("akka.routing.RoutedActorCell")
def mixinActorCellMetricsToRoutedActorCell: RouterInstrumentationAware = RouterInstrumentationAware()
}