aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2017-08-24 11:23:21 +0200
committerIvan Topolnjak <ivantopo@gmail.com>2017-08-24 11:23:21 +0200
commitcd54e4ed73734dbabebbf22e4fa288c9b047992e (patch)
tree73a94488fb9097c3e3fe1ad0271f9caadd53f6cf /kamon-core-tests
parent5291089bcc6bb048dcecad2c931f3408bd539574 (diff)
downloadKamon-cd54e4ed73734dbabebbf22e4fa288c9b047992e.tar.gz
Kamon-cd54e4ed73734dbabebbf22e4fa288c9b047992e.tar.bz2
Kamon-cd54e4ed73734dbabebbf22e4fa288c9b047992e.zip
introduce the SpanCustomizer API
Diffstat (limited to 'kamon-core-tests')
-rw-r--r--kamon-core-tests/src/test/resources/reference.conf4
-rw-r--r--kamon-core-tests/src/test/scala/kamon/trace/SpanCustomizerSpec.scala31
-rw-r--r--kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala7
3 files changed, 35 insertions, 7 deletions
diff --git a/kamon-core-tests/src/test/resources/reference.conf b/kamon-core-tests/src/test/resources/reference.conf
index efbca846..862cfa32 100644
--- a/kamon-core-tests/src/test/resources/reference.conf
+++ b/kamon-core-tests/src/test/resources/reference.conf
@@ -2,11 +2,11 @@ kamon {
context.codecs {
http-headers-keys {
- string-broadcast-key = "kamon.context.SimpleStringCodec$Headers"
+ string-broadcast-key = "kamon.testkit.SimpleStringCodec$Headers"
}
binary-keys {
- string-broadcast-key = "kamon.context.SimpleStringCodec$Binary"
+ string-broadcast-key = "kamon.testkit.SimpleStringCodec$Binary"
}
}
} \ No newline at end of file
diff --git a/kamon-core-tests/src/test/scala/kamon/trace/SpanCustomizerSpec.scala b/kamon-core-tests/src/test/scala/kamon/trace/SpanCustomizerSpec.scala
new file mode 100644
index 00000000..39bd7cd7
--- /dev/null
+++ b/kamon-core-tests/src/test/scala/kamon/trace/SpanCustomizerSpec.scala
@@ -0,0 +1,31 @@
+package kamon.trace
+
+import kamon.Kamon
+import kamon.context.Context
+import kamon.testkit.SpanInspection
+import org.scalatest.{Matchers, WordSpec}
+
+class SpanCustomizerSpec extends WordSpec with Matchers with SpanInspection {
+
+ "a SpanCustomizer" should {
+ "default to a Noop implementation when none is in the context" in {
+ val noopCustomizer = Context.Empty.get(SpanCustomizer.ContextKey)
+ val spanBuilder = noopCustomizer.customize(Kamon.buildSpan("noop"))
+ val span = inspect(spanBuilder.start())
+
+ span.operationName() shouldBe "noop"
+ span.metricTags() shouldBe empty
+ span.spanTags() shouldBe empty
+ }
+
+ "have a simple builder for customizing the operation name" in {
+ val operationNameCustomizer = SpanCustomizer.forOperationName("myCustomOperationName")
+ val spanBuilder = operationNameCustomizer.customize(Kamon.buildSpan("noop"))
+ val span = inspect(spanBuilder.start())
+
+ span.operationName() shouldBe "myCustomOperationName"
+ span.metricTags() shouldBe empty
+ span.spanTags() shouldBe empty
+ }
+ }
+}
diff --git a/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala b/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala
index b398ee98..3ad8a171 100644
--- a/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala
+++ b/kamon-core-tests/src/test/scala/kamon/trace/TracerSpec.scala
@@ -3,11 +3,11 @@ package kamon.trace
import com.typesafe.config.ConfigFactory
import kamon.Kamon
import kamon.context.Context
-import kamon.testkit.{SpanBuilding, SpanInspector}
+import kamon.testkit.{SpanBuilding, SpanInspection}
import kamon.trace.Span.TagValue
import org.scalatest.{Matchers, OptionValues, WordSpec}
-class TracerSpec extends WordSpec with Matchers with SpanBuilding with OptionValues {
+class TracerSpec extends WordSpec with Matchers with SpanBuilding with SpanInspection with OptionValues {
"the Kamon tracer" should {
"construct a minimal Span that only has a operation name" in {
@@ -100,7 +100,4 @@ class TracerSpec extends WordSpec with Matchers with SpanBuilding with OptionVal
val tracer: Tracer = Kamon
- def inspect(span: Span): SpanInspector =
- SpanInspector(span)
-
}