diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-12 11:30:06 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-02-13 05:15:30 +0100 |
commit | c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8 (patch) | |
tree | d7dbe6a1007b168998f167ac74a98744542c6fa8 /kamon-spray/src/main/scala/kamon | |
parent | 6729c9632245328a007332cdcce7d362584d735a (diff) | |
download | Kamon-c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8.tar.gz Kamon-c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8.tar.bz2 Kamon-c6bb65535bcc3cc1ff3834a91473ee8dfa6145e8.zip |
! all: Kamon now works as a single instance in a companion object.
Diffstat (limited to 'kamon-spray/src/main/scala/kamon')
3 files changed, 11 insertions, 11 deletions
diff --git a/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala b/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala index 3df8d972..ab0fe50b 100644 --- a/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala +++ b/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala @@ -21,7 +21,7 @@ import akka.actor import akka.event.{ Logging, LoggingAdapter } import kamon.Kamon import kamon.http.HttpServerMetrics -import kamon.metric.{ Entity, Metrics } +import kamon.metric.Entity import spray.http.HttpHeaders.Host import spray.http.HttpRequest @@ -46,11 +46,11 @@ class SprayExtensionImpl(system: ExtendedActorSystem) extends SprayExtension { val log = Logging(system, "SprayExtension") val httpServerMetrics = { - val metricsExtension = Metrics.get(system) + val metricsExtension = Kamon.metrics val factory = metricsExtension.instrumentFactory(HttpServerMetrics.category) val entity = Entity("spray-server", HttpServerMetrics.category) - Metrics.get(system).register(entity, new HttpServerMetrics(factory)).recorder + metricsExtension.register(entity, new HttpServerMetrics(factory)).recorder } def generateTraceName(request: HttpRequest): String = diff --git a/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala b/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala index fa9063ad..d1e9036d 100644 --- a/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala +++ b/kamon-spray/src/main/scala/kamon/spray/instrumentation/ClientRequestInstrumentation.scala @@ -16,6 +16,7 @@ package spray.can.client +import kamon.Kamon import org.aspectj.lang.annotation._ import org.aspectj.lang.ProceedingJoinPoint import spray.http._ @@ -47,7 +48,7 @@ class ClientRequestInstrumentation { requestContext.traceContext TraceContext.map { ctx ⇒ - val sprayExtension = ctx.lookupExtension(Spray) + val sprayExtension = Kamon.extension(Spray) if (sprayExtension.settings.clientInstrumentationLevel == ClientInstrumentationLevel.HostLevelAPI) { if (requestContext.segment.isEmpty) { @@ -112,7 +113,7 @@ class ClientRequestInstrumentation { (request: HttpRequest) ⇒ { TraceContext.map { ctx ⇒ - val sprayExtension = ctx.lookupExtension(Spray) + val sprayExtension = Kamon.extension(Spray) val segment = if (sprayExtension.settings.clientInstrumentationLevel == ClientInstrumentationLevel.RequestLevelAPI) ctx.startSegment(sprayExtension.generateRequestLevelApiSegmentName(request), SegmentCategory.HttpClient, Spray.SegmentLibraryName) @@ -139,7 +140,7 @@ class ClientRequestInstrumentation { def aroundIncludingDefaultHeadersAtHttpHostConnector(pjp: ProceedingJoinPoint, request: HttpMessage, defaultHeaders: List[HttpHeader]): Any = { val modifiedHeaders = TraceContext.map { ctx ⇒ - val sprayExtension = ctx.lookupExtension(Spray) + val sprayExtension = Kamon.extension(Spray) if (sprayExtension.settings.includeTraceTokenHeader) RawHeader(sprayExtension.settings.traceTokenHeaderName, ctx.token) :: defaultHeaders else diff --git a/kamon-spray/src/main/scala/kamon/spray/instrumentation/ServerRequestInstrumentation.scala b/kamon-spray/src/main/scala/kamon/spray/instrumentation/ServerRequestInstrumentation.scala index 73287132..bf20d167 100644 --- a/kamon-spray/src/main/scala/kamon/spray/instrumentation/ServerRequestInstrumentation.scala +++ b/kamon-spray/src/main/scala/kamon/spray/instrumentation/ServerRequestInstrumentation.scala @@ -39,9 +39,8 @@ class ServerRequestInstrumentation { @After("openRequestInit(openRequest, request)") def afterInit(openRequest: TraceContextAware, request: HttpRequest): Unit = { - val system: ActorSystem = openRequest.asInstanceOf[OpenRequest].context.actorContext.system - val tracer = Tracer.get(system) - val sprayExtension = Kamon(Spray)(system) + import Kamon.tracer + val sprayExtension = Kamon(Spray) val defaultTraceName = sprayExtension.generateTraceName(request) val token = if (sprayExtension.settings.includeTraceTokenHeader) { @@ -77,7 +76,7 @@ class ServerRequestInstrumentation { if (incomingContext.isEmpty) pjp.proceed() else { - val sprayExtension = incomingContext.lookupExtension(Spray) + val sprayExtension = Kamon(Spray) val proceedResult = if (sprayExtension.settings.includeTraceTokenHeader) { val responseWithHeader = includeTraceTokenIfPossible(response, sprayExtension.settings.traceTokenHeaderName, incomingContext.token) @@ -98,7 +97,7 @@ class ServerRequestInstrumentation { def verifyTraceContextConsistency(incomingTraceContext: TraceContext, storedTraceContext: TraceContext): Unit = { def publishWarning(text: String): Unit = - storedTraceContext.lookupExtension(Spray).log.warning(text) + Kamon(Spray).log.warning(text) if (incomingTraceContext.nonEmpty) { if (incomingTraceContext.token != storedTraceContext.token) |