aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2014-10-25 04:45:21 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2014-10-25 04:46:59 +0200
commitea1a0d5d76988992227eb30b0baaf8e97678c946 (patch)
tree8a6e7be43510595a6059a34c921c06c5161c7107 /kamon-core/src/test/scala/kamon/trace/TraceContextManipulationSpec.scala
parent3e2c2b3ba39ad8cca4874e3be3004f8a182dab36 (diff)
downloadKamon-ea1a0d5d76988992227eb30b0baaf8e97678c946.tar.gz
Kamon-ea1a0d5d76988992227eb30b0baaf8e97678c946.tar.bz2
Kamon-ea1a0d5d76988992227eb30b0baaf8e97678c946.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.scala24
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")
+ }
+ }
+ }
}