Class ResourceBuilder
- java.lang.Object
-
- io.opentelemetry.sdk.resources.ResourceBuilder
-
public class ResourceBuilder extends java.lang.ObjectA builder ofResourcethat allows to add key-value pairs and copy attributes from otherAttributesorResource.- Since:
- 1.1.0
-
-
Field Summary
Fields Modifier and Type Field Description private AttributesBuilderattributesBuilderprivate java.lang.StringschemaUrl
-
Constructor Summary
Constructors Constructor Description ResourceBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resourcebuild()Create theResourcefrom this.ResourceBuilderput(AttributeKey<java.lang.Long> key, int value)Puts aAttributeKeywith associated value into this.<T> ResourceBuilderput(AttributeKey<T> key, T value)Puts aAttributeKeywith associated value into this.ResourceBuilderput(java.lang.String key, boolean value)Puts a boolean attribute into this.ResourceBuilderput(java.lang.String key, boolean... values)Puts a Boolean array attribute into this.ResourceBuilderput(java.lang.String key, double value)Puts a double attribute into this.ResourceBuilderput(java.lang.String key, double... values)Puts a Double array attribute into this.ResourceBuilderput(java.lang.String key, long value)Puts a long attribute into this.ResourceBuilderput(java.lang.String key, long... values)Puts a Long array attribute into this.ResourceBuilderput(java.lang.String key, java.lang.String value)Puts a String attribute into this.ResourceBuilderput(java.lang.String key, java.lang.String... values)Puts a String array attribute into this.ResourceBuilderputAll(Attributes attributes)Puts allAttributesinto this.ResourceBuilderputAll(Resource resource)Puts all attributes fromResourceinto this.ResourceBuilderremoveIf(java.util.function.Predicate<AttributeKey<?>> filter)Remove all attributes that satisfy the given predicate fromResource.ResourceBuildersetSchemaUrl(java.lang.String schemaUrl)Assign an OpenTelemetry schema URL to the resulting Resource.
-
-
-
Field Detail
-
attributesBuilder
private final AttributesBuilder attributesBuilder
-
schemaUrl
@Nullable private java.lang.String schemaUrl
-
-
Method Detail
-
put
public ResourceBuilder put(java.lang.String key, java.lang.String value)
Puts a String attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, long value)
Puts a long attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, double value)
Puts a double attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, boolean value)
Puts a boolean attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, java.lang.String... values)
Puts a String array attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, long... values)
Puts a Long array attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, double... values)
Puts a Double array attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public ResourceBuilder put(java.lang.String key, boolean... values)
Puts a Boolean array attribute into this.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
public <T> ResourceBuilder put(AttributeKey<T> key, T value)
Puts aAttributeKeywith associated value into this.
-
put
public ResourceBuilder put(AttributeKey<java.lang.Long> key, int value)
Puts aAttributeKeywith associated value into this.
-
putAll
public ResourceBuilder putAll(Attributes attributes)
Puts allAttributesinto this.
-
putAll
public ResourceBuilder putAll(Resource resource)
Puts all attributes fromResourceinto this.
-
removeIf
public ResourceBuilder removeIf(java.util.function.Predicate<AttributeKey<?>> filter)
Remove all attributes that satisfy the given predicate fromResource.
-
setSchemaUrl
public ResourceBuilder setSchemaUrl(java.lang.String schemaUrl)
Assign an OpenTelemetry schema URL to the resulting Resource.- Parameters:
schemaUrl- The URL of the OpenTelemetry schema being used to create this Resource.- Returns:
- this
- Since:
- 1.4.0
-
-