diff options
3 files changed, 13 insertions, 22 deletions
diff --git a/kamon-spray/src/main/scala/spray/can/client/ClientRequestTracing.scala b/kamon-spray/src/main/scala/spray/can/client/ClientRequestTracing.scala index b081bf00..a1505a63 100644 --- a/kamon-spray/src/main/scala/spray/can/client/ClientRequestTracing.scala +++ b/kamon-spray/src/main/scala/spray/can/client/ClientRequestTracing.scala @@ -18,10 +18,10 @@ package spray.can.client import org.aspectj.lang.annotation._ import org.aspectj.lang.ProceedingJoinPoint -import spray.http.{HttpMessageEnd, HttpRequest} +import spray.http.{ HttpMessageEnd, HttpRequest } import spray.http.HttpHeaders.Host -import kamon.trace.{TraceContext, Trace, Segments} -import kamon.trace.Segments.{ContextAndSegmentCompletionAware, HttpClientRequest} +import kamon.trace.{ TraceContext, Trace, Segments } +import kamon.trace.Segments.{ ContextAndSegmentCompletionAware, HttpClientRequest } import kamon.trace.Trace.SegmentCompletionHandle @Aspect @@ -33,7 +33,6 @@ class ClientRequestTracing { var completionHandle: Option[SegmentCompletionHandle] = None } - @Pointcut("execution(spray.can.client.HttpHostConnector.RequestContext.new(..)) && this(ctx) && args(request, *, *, *)") def requestContextCreation(ctx: ContextAndSegmentCompletionAware, request: HttpRequest): Unit = {} @@ -43,18 +42,16 @@ class ClientRequestTracing { // completion handle the first time we create one. // The read to ctx.completionHandle should take care of initializing the aspect timely. - if(ctx.completionHandle.isEmpty) { + if (ctx.completionHandle.isEmpty) { val requestAttributes = Map[String, String]( "host" -> request.header[Host].map(_.value).getOrElse("unknown"), "path" -> request.uri.path.toString(), - "method" -> request.method.toString() - ) + "method" -> request.method.toString()) val completionHandle = Trace.startSegment(category = HttpClientRequest, attributes = requestAttributes) ctx.completionHandle = Some(completionHandle) } } - @Pointcut("execution(* spray.can.client.HttpHostConnector.RequestContext.copy(..)) && this(old)") def copyingRequestContext(old: ContextAndSegmentCompletionAware): Unit = {} @@ -65,24 +62,22 @@ class ClientRequestTracing { } } - @Pointcut("execution(* spray.can.client.HttpHostConnectionSlot.dispatchToCommander(..)) && args(requestContext, message)") def dispatchToCommander(requestContext: ContextAndSegmentCompletionAware, message: Any): Unit = {} @Around("dispatchToCommander(requestContext, message)") def aroundDispatchToCommander(pjp: ProceedingJoinPoint, requestContext: ContextAndSegmentCompletionAware, message: Any) = { requestContext.traceContext match { - case ctx @ Some(_) => + case ctx @ Some(_) ⇒ Trace.withContext(ctx) { - if(message.isInstanceOf[HttpMessageEnd]) + if (message.isInstanceOf[HttpMessageEnd]) requestContext.completionHandle.map(_.complete(Segments.End())) pjp.proceed() } - case None => pjp.proceed() + case None ⇒ pjp.proceed() } } - }
\ No newline at end of file diff --git a/kamon-trace/src/main/scala/kamon/trace/Segments.scala b/kamon-trace/src/main/scala/kamon/trace/Segments.scala index 7cc20181..0bc68ee7 100644 --- a/kamon-trace/src/main/scala/kamon/trace/Segments.scala +++ b/kamon-trace/src/main/scala/kamon/trace/Segments.scala @@ -19,19 +19,16 @@ package kamon.trace import kamon.trace.Trace.SegmentCompletionHandle object Segments { - + trait Category case object HttpClientRequest extends Category - - case class Start(category: Category, description: String = "", - attributes: Map[String, String] = Map(), timestamp: Long = System.nanoTime()) - - case class End(attributes: Map[String, String] = Map(), timestamp: Long = System.nanoTime()) - - case class Segment(start: Start, end: End) + case class Start(category: Category, description: String = "", + attributes: Map[String, String] = Map(), timestamp: Long = System.nanoTime()) + case class End(attributes: Map[String, String] = Map(), timestamp: Long = System.nanoTime()) + case class Segment(start: Start, end: End) trait SegmentCompletionHandleAware { var completionHandle: Option[SegmentCompletionHandle] diff --git a/kamon-trace/src/main/scala/kamon/trace/UowTracing.scala b/kamon-trace/src/main/scala/kamon/trace/UowTracing.scala index 7026569c..3d1a7778 100644 --- a/kamon-trace/src/main/scala/kamon/trace/UowTracing.scala +++ b/kamon-trace/src/main/scala/kamon/trace/UowTracing.scala @@ -19,7 +19,6 @@ import akka.actor._ import scala.concurrent.duration.Duration import kamon.trace.UowTracing._ - sealed trait UowSegment { def id: Long def timestamp: Long |