Class TagContextBuilder
java.lang.Object
io.opencensus.tags.TagContextBuilder
- Direct Known Subclasses:
NoopTagMapBuilder, NoopTags.NoopTagContextBuilder, TagMapBuilderImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final TagMetadataprivate static final TagMetadata -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract TagContextbuild()Creates aTagContextfrom this builder.abstract ScopeEnters the scope of code where theTagContextcreated from this builder is in the current context and returns an object that represents that scope.abstract TagContextBuilderDeprecated.put(TagKey key, TagValue value, TagMetadata tagMetadata) Adds the key/value pair and metadata regardless of whether the key is present.final TagContextBuilderAdds a non-propagating tag to thisTagContextBuilder.final TagContextBuilderputPropagating(TagKey key, TagValue value) Adds an unlimited propagating tag to thisTagContextBuilder.abstract TagContextBuilderRemoves 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
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
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
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
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
Removes the key if it exists.- Parameters:
key- theTagKeywhich will be removed.- Returns:
- this
- Since:
- 0.8
-
build
Creates aTagContextfrom this builder.- Returns:
- a
TagContextwith the same tags as this builder. - Since:
- 0.8
-
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
-
put(TagKey, TagValue, TagMetadata), orputLocal(TagKey, TagValue)if you only want in-process tags.