diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2015-01-12 01:45:27 +0100 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2015-01-24 23:19:01 +0100 |
commit | 485abe569d23bccf2d263c82b43e59464dc7e834 (patch) | |
tree | 34dd5129afe4c4705ce80830caf8d5e48212ce39 /kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala | |
parent | 61089a75240f5cc21b056087f1d633dd31981c61 (diff) | |
download | Kamon-485abe569d23bccf2d263c82b43e59464dc7e834.tar.gz Kamon-485abe569d23bccf2d263c82b43e59464dc7e834.tar.bz2 Kamon-485abe569d23bccf2d263c82b43e59464dc7e834.zip |
! all: improve the metric recorders infrastructure
Diffstat (limited to 'kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala | 76 |
1 files changed, 29 insertions, 47 deletions
diff --git a/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala b/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala index cda9cad7..0cb4ce34 100644 --- a/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/SimpleTraceSpec.scala @@ -16,58 +16,40 @@ package kamon.trace -import akka.actor.ActorSystem -import akka.testkit.{ ImplicitSender, TestKitBase } import com.typesafe.config.ConfigFactory import kamon.Kamon -import org.scalatest.{ Matchers, WordSpecLike } +import kamon.testkit.BaseKamonSpec import scala.concurrent.duration._ -class SimpleTraceSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender { - implicit lazy val system: ActorSystem = ActorSystem("simple-trace-spec", ConfigFactory.parseString( - """ - |kamon.metrics { - | tick-interval = 1 hour - | filters = [ - | { - | trace { - | includes = [ "*" ] - | excludes = [ "non-tracked-trace"] - | } - | } - | ] - | precision { - | default-histogram-precision { - | highest-trackable-value = 3600000000000 - | significant-value-digits = 2 - | } - | - | default-min-max-counter-precision { - | refresh-interval = 1 second - | highest-trackable-value = 999999999 - | significant-value-digits = 2 - | } - | } - |} - | - |kamon.trace { - | level = simple-trace - | sampling = all - |} - """.stripMargin)) +class SimpleTraceSpec extends BaseKamonSpec("simple-trace-spec") { + + override lazy val config = + ConfigFactory.parseString( + """ + |kamon { + | metric { + | tick-interval = 1 hour + | } + | + | trace { + | level-of-detail = simple-trace + | sampling = all + | } + |} + """.stripMargin) "the simple tracing" should { "send a TraceInfo when the trace has finished and all segments are finished" in { - Kamon(Trace)(system).subscribe(testActor) + Kamon(Tracer)(system).subscribe(testActor) - TraceRecorder.withNewTraceContext("simple-trace-without-segments") { - TraceRecorder.currentContext.startSegment("segment-one", "test-segment", "test").finish() - TraceRecorder.currentContext.startSegment("segment-two", "test-segment", "test").finish() - TraceRecorder.finish() + TraceContext.withContext(newContext("simple-trace-without-segments")) { + TraceContext.currentContext.startSegment("segment-one", "test-segment", "test").finish() + TraceContext.currentContext.startSegment("segment-two", "test-segment", "test").finish() + TraceContext.currentContext.finish() } val traceInfo = expectMsgType[TraceInfo] - Kamon(Trace)(system).unsubscribe(testActor) + Kamon(Tracer)(system).unsubscribe(testActor) traceInfo.name should be("simple-trace-without-segments") traceInfo.segments.size should be(2) @@ -76,12 +58,12 @@ class SimpleTraceSpec extends TestKitBase with WordSpecLike with Matchers with I } "incubate the tracing context if there are open segments after finishing" in { - Kamon(Trace)(system).subscribe(testActor) + Kamon(Tracer)(system).subscribe(testActor) - val secondSegment = TraceRecorder.withNewTraceContext("simple-trace-without-segments") { - TraceRecorder.currentContext.startSegment("segment-one", "test-segment", "test").finish() - val segment = TraceRecorder.currentContext.startSegment("segment-two", "test-segment", "test") - TraceRecorder.finish() + val secondSegment = TraceContext.withContext(newContext("simple-trace-without-segments")) { + TraceContext.currentContext.startSegment("segment-one", "test-segment", "test").finish() + val segment = TraceContext.currentContext.startSegment("segment-two", "test-segment", "test") + TraceContext.currentContext.finish() segment } @@ -90,7 +72,7 @@ class SimpleTraceSpec extends TestKitBase with WordSpecLike with Matchers with I within(10 seconds) { val traceInfo = expectMsgType[TraceInfo] - Kamon(Trace)(system).unsubscribe(testActor) + Kamon(Tracer)(system).unsubscribe(testActor) traceInfo.name should be("simple-trace-without-segments") traceInfo.segments.size should be(2) |