diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-11-09 22:55:43 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-11-09 22:56:03 +0100 |
commit | 447605e612d5bbea9765ede288ba19b1a69af48c (patch) | |
tree | 9777130efb47e31bbf262c047cb875d1cdc4724c /kamon-play/src | |
parent | 0bb57412690b8694f742d479213bda6f7f090630 (diff) | |
download | Kamon-447605e612d5bbea9765ede288ba19b1a69af48c.tar.gz Kamon-447605e612d5bbea9765ede288ba19b1a69af48c.tar.bz2 Kamon-447605e612d5bbea9765ede288ba19b1a69af48c.zip |
+ core,play,spray: allow segments to identify the library they belong to.
Diffstat (limited to 'kamon-play/src')
3 files changed, 6 insertions, 4 deletions
diff --git a/kamon-play/src/main/scala/kamon/play/Play.scala b/kamon-play/src/main/scala/kamon/play/Play.scala index 6e2de3c1..9b69f9a3 100644 --- a/kamon-play/src/main/scala/kamon/play/Play.scala +++ b/kamon-play/src/main/scala/kamon/play/Play.scala @@ -27,6 +27,8 @@ import play.api.mvc.RequestHeader object Play extends ExtensionId[PlayExtension] with ExtensionIdProvider { override def lookup(): ExtensionId[_ <: Extension] = Play override def createExtension(system: ExtendedActorSystem): PlayExtension = new PlayExtension(system) + + val SegmentLibraryName = "WS-client" } class PlayExtension(private val system: ExtendedActorSystem) extends Kamon.Extension { diff --git a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala index 125db85e..f16c76c8 100644 --- a/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala +++ b/kamon-play/src/main/scala/kamon/play/instrumentation/WSInstrumentation.scala @@ -18,7 +18,7 @@ package kamon.play.instrumentation import kamon.Kamon import kamon.play.Play -import kamon.trace.{ SegmentMetricIdentityLabel, SegmentMetricIdentity, TraceRecorder } +import kamon.trace.{ SegmentCategory, SegmentMetricIdentity, TraceRecorder } import org.aspectj.lang.ProceedingJoinPoint import org.aspectj.lang.annotation.{ Around, Aspect, Pointcut } import play.api.libs.ws.{ WSRequest, WSResponse } @@ -37,7 +37,7 @@ class WSInstrumentation { val playExtension = Kamon(Play)(system) val executor = playExtension.defaultDispatcher val segmentName = playExtension.generateHttpClientSegmentName(request) - val segment = ctx.startSegment(segmentName, SegmentMetricIdentityLabel.HttpClient) + val segment = ctx.startSegment(segmentName, SegmentCategory.HttpClient, Play.SegmentLibraryName) val response = pjp.proceed().asInstanceOf[Future[WSResponse]] response.map(result ⇒ segment.finish())(executor) diff --git a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala index bf1ead05..bda8281b 100644 --- a/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala +++ b/kamon-play/src/test/scala/kamon/play/WSInstrumentationSpec.scala @@ -19,7 +19,7 @@ package kamon.play import kamon.Kamon import kamon.metric.TraceMetrics.TraceMetricsSnapshot import kamon.metric.{ Metrics, TraceMetrics } -import kamon.trace.{ SegmentMetricIdentityLabel, SegmentMetricIdentity, TraceRecorder } +import kamon.trace.{ SegmentCategory, SegmentMetricIdentity, TraceRecorder } import org.scalatest.{ Matchers, WordSpecLike } import org.scalatestplus.play.OneServerPerSuite import play.api.libs.ws.WS @@ -49,7 +49,7 @@ class WSInstrumentationSpec extends WordSpecLike with Matchers with OneServerPer val snapshot = takeSnapshotOf("GET: /inside") snapshot.elapsedTime.numberOfMeasurements should be(1) snapshot.segments.size should be(1) - snapshot.segments(SegmentMetricIdentity("http://localhost:19001/async", SegmentMetricIdentityLabel.HttpClient)).numberOfMeasurements should be(1) + snapshot.segments(SegmentMetricIdentity("http://localhost:19001/async", SegmentCategory.HttpClient, Play.SegmentLibraryName)).numberOfMeasurements should be(1) } "propagate the TraceContext outside an Action and complete the WS request" in { |