diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2014-10-25 04:45:21 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2014-10-25 04:46:59 +0200 |
commit | 096b35f93a0bafb3b0b6932d75e8d5f087cd4b2e (patch) | |
tree | 156f73c7b2145b21930d52275e47cb8b674bb27a /kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala | |
parent | 30940181424be69e0fd64e945fe5a64b4523457b (diff) | |
download | Kamon-096b35f93a0bafb3b0b6932d75e8d5f087cd4b2e.tar.gz Kamon-096b35f93a0bafb3b0b6932d75e8d5f087cd4b2e.tar.bz2 Kamon-096b35f93a0bafb3b0b6932d75e8d5f087cd4b2e.zip |
! core: replace Option[TraceContext] by empty object pattern and implement basic segments with renaming.
Diffstat (limited to 'kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala')
-rw-r--r-- | kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala b/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala index 4d0049f1..e2031a72 100644 --- a/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala +++ b/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala @@ -3,7 +3,6 @@ package kamon.trace import akka.actor.ActorSystem import akka.testkit.{ ImplicitSender, TestKitBase } import com.typesafe.config.ConfigFactory -import kamon.trace.TraceContext.SegmentIdentity import org.scalatest.{ Matchers, WordSpecLike } class TraceContextManipulationSpec extends TestKitBase with WordSpecLike with Matchers with ImplicitSender { @@ -38,7 +37,7 @@ class TraceContextManipulationSpec extends TestKitBase with WordSpecLike with Ma "allow starting a trace within a specified block of code, and only within that block of code" in { val createdContext = TraceRecorder.withNewTraceContext("start-context") { TraceRecorder.currentContext should not be empty - TraceRecorder.currentContext.get + TraceRecorder.currentContext } TraceRecorder.currentContext shouldBe empty @@ -48,7 +47,7 @@ class TraceContextManipulationSpec extends TestKitBase with WordSpecLike with Ma "allow starting a trace within a specified block of code, providing a trace-token and only within that block of code" in { val createdContext = TraceRecorder.withNewTraceContext("start-context-with-token", Some("token-1")) { TraceRecorder.currentContext should not be empty - TraceRecorder.currentContext.get + TraceRecorder.currentContext } TraceRecorder.currentContext shouldBe empty @@ -70,7 +69,7 @@ class TraceContextManipulationSpec extends TestKitBase with WordSpecLike with Ma "allow renaming a trace" in { val createdContext = TraceRecorder.withNewTraceContext("trace-before-rename") { TraceRecorder.rename("renamed-trace") - TraceRecorder.currentContext.get + TraceRecorder.currentContext } TraceRecorder.currentContext shouldBe empty @@ -79,17 +78,22 @@ class TraceContextManipulationSpec extends TestKitBase with WordSpecLike with Ma "allow creating a segment within a trace" in { val createdContext = TraceRecorder.withNewTraceContext("trace-with-segments") { - val segmentHandle = TraceRecorder.startSegment(TraceManipulationTestSegment("segment-1")) - - TraceRecorder.currentContext.get + val segment = TraceRecorder.currentContext.startSegment("segment-1", "segment-1-label") + TraceRecorder.currentContext } TraceRecorder.currentContext shouldBe empty createdContext.name shouldBe ("trace-with-segments") - } - } - case class TraceManipulationTestSegment(name: String) extends SegmentIdentity + "allow renaming a segment" in { + TraceRecorder.withNewTraceContext("trace-with-renamed-segment") { + val segment = TraceRecorder.currentContext.startSegment("original-segment-name", "segment-label") + segment.name should be("original-segment-name") + segment.rename("new-segment-name") + segment.name should be("new-segment-name") + } + } + } } |