Interface AttributesBuilder
Attributes supporting an arbitrary number of key-value pairs.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Create theAttributesfrom this.put(AttributeKey<Long> key, int value) Puts aAttributeKeywith associated value into this.default <T> AttributesBuilderput(AttributeKey<List<T>> key, T... value) Puts a List attribute into this.put(AttributeKey<T> key, T value) Puts anAttributeKeywith an associated value into this if the value is non-null.default AttributesBuilderPuts a boolean attribute into this.default AttributesBuilderPuts a Boolean array attribute into this.default AttributesBuilderPuts a double attribute into this.default AttributesBuilderPuts a Double array attribute into this.default AttributesBuilderPuts a long attribute into this.default AttributesBuilderPuts a Long array attribute into this.default AttributesBuilderPuts aValueattribute into this.default AttributesBuilderPuts a String attribute into this if the value is non-null.default AttributesBuilderPuts a String array attribute into this.putAll(Attributes attributes) Puts all the provided attributes into this Builder.default <T> AttributesBuilderremove(AttributeKey<T> key) default AttributesBuilderremoveIf(Predicate<AttributeKey<?>> filter) Remove all attributes that satisfy the given predicate.
-
Method Details
-
build
Attributes build()Create theAttributesfrom this. -
put
Puts aAttributeKeywith associated value into this.The type parameter is unused.
-
put
Puts anAttributeKeywith 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 (
AttributeType.STRING,AttributeType.LONG,AttributeType.DOUBLE,AttributeType.BOOLEAN,AttributeType.STRING_ARRAY,AttributeType.LONG_ARRAY,AttributeType.DOUBLE_ARRAY,AttributeType.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 (
AttributeType.VALUE) to simple attributes when possible.- Calling
put(AttributeKey.valueKey("key"), Value.of("a"))is equivalent to callingput(AttributeKey.stringKey("key"), "a"). - Calling
put(AttributeKey.valueKey("key"), Value.of(1L))is equivalent to callingput(AttributeKey.longKey("key"), 1L). - Calling
put(AttributeKey.valueKey("key"), Value.of(1.0))is equivalent to callingput(AttributeKey.doubleKey("key"), 1.0). - Calling
put(AttributeKey.valueKey("key"), Value.of(true))is equivalent to callingput(AttributeKey.booleanKey("key"), true). - Calling
put(AttributeKey.valueKey("key"), Value.of(Value.of("a"), Value.of("b")))is equivalent to callingput(AttributeKey.stringArrayKey("key"), Arrays.asList("a", "b")). - Calling
put(AttributeKey.valueKey("key"), Value.of(Value.of(1L), Value.of(2L)))is equivalent to callingput(AttributeKey.longArrayKey("key"), Arrays.asList(1L, 2L)). - Calling
put(AttributeKey.valueKey("key"), Value.of(Value.of(1.0), Value.of(2.0)))is equivalent to callingput(AttributeKey.doubleArrayKey("key"), Arrays.asList(1.0, 2.0)). - Calling
put(AttributeKey.valueKey("key"), Value.of(Value.of(true), Value.of(false)))is equivalent to callingput(AttributeKey.booleanArrayKey("key"), Arrays.asList(true, false)).
- Calling
-
put
Puts a String attribute into this if the value is non-null. Providing a null value does not remove or unset previously set values.Note: It is strongly recommended to use
put(AttributeKey, 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(AttributeKey, 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(AttributeKey, 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(AttributeKey, 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(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
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(AttributeKey, 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(AttributeKey, 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(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
-
put
Puts aValueattribute into this. Seeput(AttributeKey, Object)for details on how this method will automatically convertValueattributes to simple attributes when possible.Note: It is strongly recommended to use
put(AttributeKey, Object), and pre-allocate your keys, if possible.- Returns:
- this Builder
- Since:
- 1.59.0
-
putAll
Puts all the provided attributes into this Builder.- Returns:
- this Builder
-
remove
- 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
-