Interface ExtendedAttributesBuilder
ExtendedAttributes supporting an arbitrary number of key-value pairs.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Create theExtendedAttributesfrom this.default <T> ExtendedAttributesBuilderPuts a List attribute into this.default <T> ExtendedAttributesBuilderput(io.opentelemetry.api.common.AttributeKey<T> key, T value) Puts aAttributeKeywith associated value into this.put(ExtendedAttributeKey<T> key, T value) Puts anExtendedAttributeKeywith an associated value into this if the value is non-null.default ExtendedAttributesBuilderPuts a boolean attribute into this.default ExtendedAttributesBuilderPuts a Boolean array attribute into this.default ExtendedAttributesBuilderPuts a double attribute into this.default ExtendedAttributesBuilderPuts a Double array attribute into this.default ExtendedAttributesBuilderPuts a long attribute into this.default ExtendedAttributesBuilderPuts a Long array attribute into this.default <T> ExtendedAttributesBuilderput(String key, ExtendedAttributes value) Deprecated.default ExtendedAttributesBuilderPuts a String attribute into this.default ExtendedAttributesBuilderPuts a String array attribute into this.default ExtendedAttributesBuilderputAll(io.opentelemetry.api.common.Attributes attributes) Puts all the provided attributes into this Builder.default ExtendedAttributesBuilderputAll(ExtendedAttributes attributes) Puts all the provided attributes into this Builder.default <T> ExtendedAttributesBuilderremove(io.opentelemetry.api.common.AttributeKey<T> key) Remove all attributes whereAttributeKey.getKey()andAttributeKey.getType()match thekey.default <T> ExtendedAttributesBuilderremove(ExtendedAttributeKey<T> key) Remove all attributes whereExtendedAttributeKey.getKey()andExtendedAttributeKey.getType()match thekey.removeIf(Predicate<ExtendedAttributeKey<?>> filter) Remove all attributes that satisfy the given predicate.
-
Method Details
-
build
ExtendedAttributes build()Create theExtendedAttributesfrom this. -
put
Puts aAttributeKeywith associated value into this. -
put
Puts anExtendedAttributeKeywith an associated value into this if the value is non-null. Providing a null value does not remove or unset previously set values.Simple attributes (
ExtendedAttributeType.STRING,ExtendedAttributeType.LONG,ExtendedAttributeType.DOUBLE,ExtendedAttributeType.BOOLEAN,ExtendedAttributeType.STRING_ARRAY,ExtendedAttributeType.LONG_ARRAY,ExtendedAttributeType.DOUBLE_ARRAY,ExtendedAttributeType.BOOLEAN_ARRAY) SHOULD be used whenever possible. Instrumentations SHOULD assume that backends do not index individual properties of complex attributes, that querying or aggregating on such properties is inefficient and complicated, and that reporting complex attributes carries higher performance overhead.Note: This method will automatically convert complex attributes (
ExtendedAttributeType.VALUE) to simple attributes when possible.- Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of("a"))is equivalent to callingput(ExtendedAttributeKey.stringKey("key"), "a"). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(1L))is equivalent to callingput(ExtendedAttributeKey.longKey("key"), 1L). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(1.0))is equivalent to callingput(ExtendedAttributeKey.doubleKey("key"), 1.0). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(true))is equivalent to callingput(ExtendedAttributeKey.booleanKey("key"), true). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(Value.of("a"), Value.of("b")))is equivalent to callingput(ExtendedAttributeKey.stringArrayKey("key"), Arrays.asList("a", "b")). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(Value.of(1L), Value.of(2L)))is equivalent to callingput(ExtendedAttributeKey.longArrayKey("key"), Arrays.asList(1L, 2L)). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(Value.of(1.0), Value.of(2.0)))is equivalent to callingput(ExtendedAttributeKey.doubleArrayKey("key"), Arrays.asList(1.0, 2.0)). - Calling
put(ExtendedAttributeKey.valueKey("key"), Value.of(Value.of(true), Value.of(false)))is equivalent to callingput(ExtendedAttributeKey.booleanArrayKey("key"), Arrays.asList(true, false)).
- Calling
-
put
Puts a String attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts a long attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts a double attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts a boolean attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Deprecated.Useput(ExtendedAttributeKey, Object)withValue.of(java.util.Map)instead.Puts aExtendedAttributesattribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts a String array attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
default <T> ExtendedAttributesBuilder put(io.opentelemetry.api.common.AttributeKey<List<T>> key, T... value) Puts a List attribute into this.- Returns:
- this Builder
-
put
Puts a Long array attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts a Double array attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts a Boolean array attribute into this.Note: It is strongly recommended to use
put(ExtendedAttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
putAll
Puts all the provided attributes into this Builder.- Returns:
- this Builder
-
putAll
Puts all the provided attributes into this Builder.- Returns:
- this Builder
-
remove
Remove all attributes whereAttributeKey.getKey()andAttributeKey.getType()match thekey.- Returns:
- this Builder
-
remove
Remove all attributes whereExtendedAttributeKey.getKey()andExtendedAttributeKey.getType()match thekey.- Returns:
- this Builder
-
removeIf
Remove all attributes that satisfy the given predicate. Errors or runtime exceptions thrown by the predicate are relayed to the caller.- Returns:
- this Builder
-
put(ExtendedAttributeKey, Object)withValue.of(java.util.Map)instead.