diff options
author | Ivan Topolnjak <ivantopo@gmail.com> | 2018-09-28 16:26:06 +0200 |
---|---|---|
committer | Ivan Topolnjak <ivantopo@gmail.com> | 2018-09-28 16:26:06 +0200 |
commit | 87cf9bd2b33f153e3ba070c75f7f496005cac295 (patch) | |
tree | a4f6e9fbf19191a2ebe08a69c1537b2ec7a08e4d /kamon-core/src/main | |
parent | c6c4f039f00e1580fc6782fd1e75845466842549 (diff) | |
download | Kamon-87cf9bd2b33f153e3ba070c75f7f496005cac295.tar.gz Kamon-87cf9bd2b33f153e3ba070c75f7f496005cac295.tar.bz2 Kamon-87cf9bd2b33f153e3ba070c75f7f496005cac295.zip |
restor the HasContext mixin
Diffstat (limited to 'kamon-core/src/main')
-rw-r--r-- | kamon-core/src/main/scala/kamon/instrumentation/Mixin.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/instrumentation/Mixin.scala b/kamon-core/src/main/scala/kamon/instrumentation/Mixin.scala new file mode 100644 index 00000000..f5a5e63b --- /dev/null +++ b/kamon-core/src/main/scala/kamon/instrumentation/Mixin.scala @@ -0,0 +1,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()) + } +} |