blob: 4c6220cea3b4ffdffbeb7583fa777f05bf381ac2 (
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
32
33
34
35
|
package kamon.trace
import kamon.context.Key
import kamon.trace.Tracer.SpanBuilder
/**
* Allows users to customize and add additional information to Spans created by instrumentation. The typical use
* case for SpanCustomizer instances is to provide proper operation names in situations where the instrumentation
* is unable to generate a reasonable enough operation name, e.g. JDBC and HTTP Client calls, instead of having a
* default operation name using the statement type or target host a SpanCustomizer can be provided to assign operation
* names like "queryUsers" or "getUserProfile" instead.
*
* Instrumentation wanting to take advantage of SpanCustomizers should look for an instance in the current context
* using SpanCustomizer.ContextKey.
*
*/
trait SpanCustomizer {
def customize(spanBuilder: SpanBuilder): SpanBuilder
}
object SpanCustomizer {
val Noop = new SpanCustomizer {
override def customize(spanBuilder: SpanBuilder): SpanBuilder = spanBuilder
}
val ContextKey = Key.local[SpanCustomizer]("span-customizer", Noop)
def forOperationName(operationName: String): SpanCustomizer = new SpanCustomizer {
override def customize(spanBuilder: SpanBuilder): SpanBuilder =
spanBuilder.withOperationName(operationName)
}
}
|