aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/tag/Tag.scala
diff options
context:
space:
mode:
authorIvan Topolnjak <ivantopo@gmail.com>2019-04-01 13:26:18 +0200
committerGitHub <noreply@github.com>2019-04-01 13:26:18 +0200
commit45237e2977d38053ddedc35765a901cf8771c106 (patch)
tree4c8ce6da2630dc92dc9f2b4d440b206177a4ab89 /kamon-core/src/main/scala/kamon/tag/Tag.scala
parent8efb3b408a876a3dfdac79580773279125cb4135 (diff)
parent2392fb02c3259d7f0b41ff410641accd818bc5d4 (diff)
downloadKamon-master.tar.gz
Kamon-master.tar.bz2
Kamon-master.zip
Merge pull request #572 from ivantopo/tagsHEADmaster
Introduce a common abstractions to handle tags
Diffstat (limited to 'kamon-core/src/main/scala/kamon/tag/Tag.scala')
-rw-r--r--kamon-core/src/main/scala/kamon/tag/Tag.scala50
1 files changed, 50 insertions, 0 deletions
diff --git a/kamon-core/src/main/scala/kamon/tag/Tag.scala b/kamon-core/src/main/scala/kamon/tag/Tag.scala
new file mode 100644
index 00000000..69a5d7e7
--- /dev/null
+++ b/kamon-core/src/main/scala/kamon/tag/Tag.scala
@@ -0,0 +1,50 @@
+package kamon.tag
+
+import java.lang.{Boolean => JBoolean, Long => JLong, String => JString}
+
+/**
+ * Marker trait for allowed Tag implementations. Users are not meant to create implementations of this trait outside
+ * of Kamon. Furthermore, users of TagSet might never need to interact with these classes but rather perform lookups
+ * using the lookup DSL.
+ */
+sealed trait Tag {
+ def key: JString
+}
+
+object Tag {
+
+ /**
+ * Represents a String key pointing to a String value.
+ */
+ trait String extends Tag {
+ def value: JString
+ }
+
+
+ /**
+ * Represents a String key pointing to a Boolean value.
+ */
+ trait Boolean extends Tag {
+ def value: JBoolean
+ }
+
+
+ /**
+ * Represents a String key pointing to a Long value.
+ */
+ trait Long extends Tag {
+ def value: JLong
+ }
+
+
+ /**
+ * Returns the value held inside of a Tag instance. This utility function is specially useful when iterating over
+ * tags but not caring about the concrete tag type.
+ */
+ def unwrapValue(tag: Tag): Any = tag match {
+ case t: Tag.String => t.value
+ case t: Tag.Boolean => t.value
+ case t: Tag.Long => t.value
+ }
+}
+