aboutsummaryrefslogtreecommitdiff
path: root/kamon-core-tests/src/test/scala/kamon/trace/SpanCustomizerSpec.scala
blob: 39bd7cd74da73d37a28ac95e46b4ef61c0bb6fb5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
    }
  }
}