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.ObjectBuilder for theTagContextclass.- Since:
- 0.8
-
-
Field Summary
Fields Modifier and Type Field Description private static TagMetadataMETADATA_NO_PROPAGATIONprivate static TagMetadataMETADATA_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 TagContextbuild()Creates aTagContextfrom this builder.abstract ScopebuildScoped()Enters the scope of code where theTagContextcreated from this builder is in the current context and returns an object that represents that scope.abstract TagContextBuilderput(TagKey key, TagValue value)Deprecated.in favor ofput(TagKey, TagValue, TagMetadata), orputLocal(TagKey, TagValue)if you only want in-process tags.TagContextBuilderput(TagKey key, TagValue value, TagMetadata tagMetadata)Adds the key/value pair and metadata regardless of whether the key is present.TagContextBuilderputLocal(TagKey key, TagValue value)Adds a non-propagating tag to thisTagContextBuilder.TagContextBuilderputPropagating(TagKey key, TagValue value)Adds an unlimited propagating tag to thisTagContextBuilder.abstract TagContextBuilderremove(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
Tags.Equivalent to calling
put(key, value, TagMetadata.create(TagTtl.UNLIMITED_PROPAGATION)).- Parameters:
key- theTagKeywhich will be set.value- theTagValueto 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- theTagKeywhich will be set.value- theTagValueto set for the given key.tagMetadata- theTagMetadataassociated 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- theTagKeywhich will be set.value- theTagValueto 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- theTagKeywhich will be set.value- theTagValueto 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- theTagKeywhich will be removed.- Returns:
- this
- Since:
- 0.8
-
build
public abstract TagContext build()
Creates aTagContextfrom this builder.- Returns:
- a
TagContextwith the same tags as this builder. - Since:
- 0.8
-
buildScoped
public abstract Scope buildScoped()
Enters the scope of code where theTagContextcreated 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
TagContextcreated from this builder is set to the current context. - Since:
- 0.8
-
-