Package io.opencensus.tags
Class TagContextBuilder
java.lang.Object
io.opencensus.tags.TagContextBuilder
- Direct Known Subclasses:
NoopTagMapBuilder
,NoopTags.NoopTagContextBuilder
,TagMapBuilderImpl
Builder for the
TagContext
class.- Since:
- 0.8
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final TagMetadata
private static final TagMetadata
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract TagContext
build()
Creates aTagContext
from this builder.abstract Scope
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
Deprecated.put
(TagKey key, TagValue value, TagMetadata tagMetadata) Adds the key/value pair and metadata regardless of whether the key is present.final TagContextBuilder
Adds a non-propagating tag to thisTagContextBuilder
.final TagContextBuilder
putPropagating
(TagKey key, TagValue value) Adds an unlimited propagating tag to thisTagContextBuilder
.abstract TagContextBuilder
Removes the key if it exists.
-
Field Details
-
METADATA_NO_PROPAGATION
-
METADATA_UNLIMITED_PROPAGATION
-
-
Constructor Details
-
TagContextBuilder
public TagContextBuilder()
-
-
Method Details
-
put
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
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
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
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
Removes the key if it exists.- Parameters:
key
- theTagKey
which will be removed.- Returns:
- this
- Since:
- 0.8
-
build
Creates aTagContext
from this builder.- Returns:
- a
TagContext
with the same tags as this builder. - Since:
- 0.8
-
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
-
put(TagKey, TagValue, TagMetadata)
, orputLocal(TagKey, TagValue)
if you only want in-process tags.