diff options
Diffstat (limited to 'kamon-spray/src')
-rw-r--r-- | kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala | 5 | ||||
-rw-r--r-- | kamon-spray/src/test/scala/kamon/spray/ClientRequestInstrumentationSpec.scala | 32 |
2 files changed, 25 insertions, 12 deletions
diff --git a/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala b/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala index ab0fe50b..a5aa33cb 100644 --- a/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala +++ b/kamon-spray/src/main/scala/kamon/spray/SprayExtension.scala @@ -46,11 +46,8 @@ class SprayExtensionImpl(system: ExtendedActorSystem) extends SprayExtension { val log = Logging(system, "SprayExtension") val httpServerMetrics = { - val metricsExtension = Kamon.metrics - val factory = metricsExtension.instrumentFactory(HttpServerMetrics.category) val entity = Entity("spray-server", HttpServerMetrics.category) - - metricsExtension.register(entity, new HttpServerMetrics(factory)).recorder + Kamon.metrics.entity(HttpServerMetrics, entity) } def generateTraceName(request: HttpRequest): String = diff --git a/kamon-spray/src/test/scala/kamon/spray/ClientRequestInstrumentationSpec.scala b/kamon-spray/src/test/scala/kamon/spray/ClientRequestInstrumentationSpec.scala index 67e6725f..4b99022e 100644 --- a/kamon-spray/src/test/scala/kamon/spray/ClientRequestInstrumentationSpec.scala +++ b/kamon-spray/src/test/scala/kamon/spray/ClientRequestInstrumentationSpec.scala @@ -34,8 +34,6 @@ import scala.concurrent.duration._ class ClientRequestInstrumentationSpec extends BaseKamonSpec("client-request-instrumentation-spec") with ScalaFutures with RequestBuilding with TestServer { - import TraceMetricsSpec.SegmentSyntax - override lazy val config = ConfigFactory.parseString( """ @@ -130,8 +128,14 @@ class ClientRequestInstrumentationSpec extends BaseKamonSpec("client-request-ins val traceMetricsSnapshot = takeSnapshotOf("assign-name-to-segment-with-request-level-api", "trace") traceMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) - traceMetricsSnapshot.segment("request-level /request-level-api-segment", SegmentCategory.HttpClient, Spray.SegmentLibraryName) - .numberOfMeasurements should be(1) + + val segmentMetricsSnapshot = takeSnapshotOf("request-level /request-level-api-segment", "trace-segment", + tags = Map( + "trace" -> "assign-name-to-segment-with-request-level-api", + "category" -> SegmentCategory.HttpClient, + "library" -> Spray.SegmentLibraryName)) + + segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } "rename a request level api segment once it reaches the relevant host connector" in { @@ -161,8 +165,14 @@ class ClientRequestInstrumentationSpec extends BaseKamonSpec("client-request-ins val traceMetricsSnapshot = takeSnapshotOf("rename-segment-with-request-level-api", "trace") traceMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) - traceMetricsSnapshot.segment("host-level /request-level-api-segment", SegmentCategory.HttpClient, Spray.SegmentLibraryName) - .numberOfMeasurements should be(1) + + val segmentMetricsSnapshot = takeSnapshotOf("host-level /request-level-api-segment", "trace-segment", + tags = Map( + "trace" -> "rename-segment-with-request-level-api", + "category" -> SegmentCategory.HttpClient, + "library" -> Spray.SegmentLibraryName)) + + segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } } @@ -249,8 +259,14 @@ class ClientRequestInstrumentationSpec extends BaseKamonSpec("client-request-ins val traceMetricsSnapshot = takeSnapshotOf("create-segment-with-host-level-api", "trace") traceMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) - traceMetricsSnapshot.segment("host-level /host-level-api-segment", SegmentCategory.HttpClient, Spray.SegmentLibraryName) - .numberOfMeasurements should be(1) + + val segmentMetricsSnapshot = takeSnapshotOf("host-level /host-level-api-segment", "trace-segment", + tags = Map( + "trace" -> "create-segment-with-host-level-api", + "category" -> SegmentCategory.HttpClient, + "library" -> Spray.SegmentLibraryName)) + + segmentMetricsSnapshot.histogram("elapsed-time").get.numberOfMeasurements should be(1) } } } |