class TagSet extends AnyRef
A immutable collection of key/value pairs with specialized support for storing String keys pointing to String, Long and/or Boolean values.
Instances of Tags store all pairs in the same data structure, but preserving type information for the stored pairs and providing a simple DSL for accessing those values and expressing type expectations. It is also possible to lookup pairs without prescribing a mechanism for handling missing values. I.e. users of this class can decide whether to receive a null, java.util.Optional, scala.Option or any other value when looking up a pair.
TagSet instances can only be created from the builder functions on the TagSet companion object. There are two different options to read the contained pairs from a Tags instance:
- Using the lookup DSL. You can use the Lookup DSL when you know exactly that you are trying to get out of the tags instance. The lookup DSL is biased towards String keys since they are by far the most common case. For example, to get a given tag as an Option[String] and another as an Option[Boolean] the following code should suffice:
import kamon.tag.Tags.Lookup._ val tags = Tags.from(tagMap) val name = tags.get(option("name")) val isSignedIn = tags.get(booleanOption("isSignedIn"))
2. Using the .all() and .iterator variants. This option requires you to test the returned instances to verify whether they are a Tag.String, Tag.Long or Tag.Boolean instance and act accordingly. Fortunately this cumbersome operation is rarely necessary on user-facing code.
- Alphabetic
- By Inheritance
- TagSet
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def all(): Seq[Tag]
Returns a immutable sequence of tags created from the contained tags internal representation.
Returns a immutable sequence of tags created from the contained tags internal representation. Calling this method will cause the creation of a new data structure. Unless you really need to have all the tags as immutable instances it is recommended to use the .iterator() function instead.
The returned sequence contains immutable values and is safe to share across threads.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(other: Any): Boolean
- Definition Classes
- TagSet → AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def get[T](lookup: Lookup[T]): T
Executes a tag lookup.
Executes a tag lookup. The return type of this function will depend on the provided Lookup. Take a look at the built-in lookups on the Lookups companion object for more information.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- TagSet → AnyRef → Any
- def isEmpty(): Boolean
Returns whether this TagSet instance does not contain any tags.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator(): Iterator[Tag]
Returns an iterator of tags.
Returns an iterator of tags. The underlying iterator reuses the Tag instances to avoid unnecessary intermediate allocations and thus, it is not safe to share across threads. The most common case for tags iterators is on reporters which will need to iterate through all existent tags only to copy their values into a separate data structure that will be sent to the external systems.
- def iterator[T](valueTransform: (Any) => T): Iterator[Pair[T]]
Returns a pairs iterator from this TagSet.
Returns a pairs iterator from this TagSet. All values are transformed using the provided valueTransform before being returned by the iterator.
- def iterator[T](valueTransform: Function[Any, T]): Iterator[Pair[T]]
Returns a pairs iterator from this TagSet.
Returns a pairs iterator from this TagSet. All values are transformed using the provided valueTransform before being returned by the iterator.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def nonEmpty(): Boolean
Returns whether this TagSet instance contains any tags.
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- TagSet → AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withTag(key: String, value: Long): TagSet
Creates a new TagSet instance that includes the provided key/value pair.
Creates a new TagSet instance that includes the provided key/value pair. If the provided key was already associated with another value then the previous value will be discarded and overwritten with the provided one.
- def withTag(key: String, value: Boolean): TagSet
Creates a new TagSet instance that includes the provided key/value pair.
Creates a new TagSet instance that includes the provided key/value pair. If the provided key was already associated with another value then the previous value will be discarded and overwritten with the provided one.
- def withTag(key: String, value: String): TagSet
Creates a new TagSet instance that includes the provided key/value pair.
Creates a new TagSet instance that includes the provided key/value pair. If the provided key was already associated with another value then the previous value will be discarded and overwritten with the provided one.
- def withTags(other: TagSet): TagSet
Creates a new TagSet instance that includes all the tags from the provided Tags instance.
Creates a new TagSet instance that includes all the tags from the provided Tags instance. If any of the tags in this instance are associated to a key present on the provided instance then the previous value will be discarded and overwritten with the provided one.
- def without(key: String): TagSet
Creates a new TagSet instance without the provided key, if it was present.