Package io.opencensus.tags
Class TagContextBuilder
- java.lang.Object
-
- io.opencensus.tags.TagContextBuilder
-
- Direct Known Subclasses:
NoopTagMapBuilder
,NoopTags.NoopTagContextBuilder
,TagMapBuilderImpl
public abstract class TagContextBuilder extends java.lang.Object
Builder for theTagContext
class.- Since:
- 0.8
-
-
Field Summary
Fields Modifier and Type Field Description private static TagMetadata
METADATA_NO_PROPAGATION
private static TagMetadata
METADATA_UNLIMITED_PROPAGATION
-
Constructor Summary
Constructors Constructor Description TagContextBuilder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract TagContext
build()
Creates aTagContext
from this builder.abstract Scope
buildScoped()
Enters the scope of code where theTagContext
created from this builder is in the current context and returns an object that represents that scope.abstract TagContextBuilder
put(TagKey key, TagValue value)
Deprecated.in favor ofput(TagKey, TagValue, TagMetadata)
, orputLocal(TagKey, TagValue)
if you only want in-process tags.TagContextBuilder
put(TagKey key, TagValue value, TagMetadata tagMetadata)
Adds the key/value pair and metadata regardless of whether the key is present.TagContextBuilder
putLocal(TagKey key, TagValue value)
Adds a non-propagating tag to thisTagContextBuilder
.TagContextBuilder
putPropagating(TagKey key, TagValue value)
Adds an unlimited propagating tag to thisTagContextBuilder
.abstract TagContextBuilder
remove(TagKey key)
Removes the key if it exists.
-
-
-
Field Detail
-
METADATA_NO_PROPAGATION
private static final TagMetadata METADATA_NO_PROPAGATION
-
METADATA_UNLIMITED_PROPAGATION
private static final TagMetadata METADATA_UNLIMITED_PROPAGATION
-
-
Method Detail
-
put
@Deprecated public abstract TagContextBuilder put(TagKey key, TagValue value)
Deprecated.in favor ofput(TagKey, TagValue, TagMetadata)
, orputLocal(TagKey, TagValue)
if you only want in-process tags.Adds the key/value pair regardless of whether the key is present.For backwards-compatibility this method still produces propagating
Tag
s.Equivalent to calling
put(key, value, TagMetadata.create(TagTtl.UNLIMITED_PROPAGATION))
.- Parameters:
key
- theTagKey
which will be set.value
- theTagValue
to set for the given key.- Returns:
- this
- Since:
- 0.8
-
put
public TagContextBuilder put(TagKey key, TagValue value, TagMetadata tagMetadata)
Adds the key/value pair and metadata regardless of whether the key is present.- Parameters:
key
- theTagKey
which will be set.value
- theTagValue
to set for the given key.tagMetadata
- theTagMetadata
associated with thisTag
.- Returns:
- this
- Since:
- 0.20
-
putLocal
public final TagContextBuilder putLocal(TagKey key, TagValue value)
Adds a non-propagating tag to thisTagContextBuilder
.This is equivalent to calling
put(key, value, TagMetadata.create(TagTtl.NO_PROPAGATION))
.- Parameters:
key
- theTagKey
which will be set.value
- theTagValue
to set for the given key.- Returns:
- this
- Since:
- 0.21
-
putPropagating
public final TagContextBuilder putPropagating(TagKey key, TagValue value)
Adds an unlimited propagating tag to thisTagContextBuilder
.This is equivalent to calling
put(key, value, TagMetadata.create(TagTtl.METADATA_UNLIMITED_PROPAGATION))
.Only call this method if you want propagating tags. If you want tags for breaking down metrics, or there are sensitive messages in your tags, use
putLocal(TagKey, TagValue)
instead.- Parameters:
key
- theTagKey
which will be set.value
- theTagValue
to set for the given key.- Returns:
- this
- Since:
- 0.21
-
remove
public abstract TagContextBuilder remove(TagKey key)
Removes the key if it exists.- Parameters:
key
- theTagKey
which will be removed.- Returns:
- this
- Since:
- 0.8
-
build
public abstract TagContext build()
Creates aTagContext
from this builder.- Returns:
- a
TagContext
with the same tags as this builder. - Since:
- 0.8
-
buildScoped
public abstract Scope buildScoped()
Enters the scope of code where theTagContext
created from this builder is in the current context and returns an object that represents that scope. The scope is exited when the returned object is closed.- Returns:
- an object that defines a scope where the
TagContext
created from this builder is set to the current context. - Since:
- 0.8
-
-