blob: f5a5e63b63eb5d53d093c22865913cc328d46a0e (
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
36
|
package kamon.instrumentation
import kamon.Kamon
import kamon.context.Context
/**
* Common mixins used across multiple instrumentation modules.
*/
object Mixin {
/**
* Utility trait that marks objects carrying a reference to a Context instance.
*
*/
trait HasContext {
def context: Context
}
object HasContext {
private case class Default(context: Context) extends HasContext
/**
* Construct a HasSpan instance that references the provided Context.
*
*/
def from(context: Context): HasContext =
Default(context)
/**
* Construct a HasContext instance with the current Kamon from Kamon's default context storage.
*
*/
def fromCurrentContext(): HasContext =
Default(Kamon.currentContext())
}
}
|