Skip to content

Commit 42d4b8a

Browse files
committed
more javadoc
1 parent 5cfe4ab commit 42d4b8a

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

api/all/src/main/java/io/opentelemetry/api/common/AttributeType.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ public enum AttributeType {
1919
LONG_ARRAY,
2020
DOUBLE_ARRAY,
2121
/**
22-
* Simple attributes (i.e. anything other than {@code VALUE} attributes) SHOULD be used whenever
23-
* possible. Instrumentations SHOULD assume that backends do not index individual properties of
24-
* complex attributes, that querying or aggregating on such properties is inefficient and
25-
* complicated, and that reporting complex attributes carries higher performance overhead.
22+
* Simple attributes ({@link AttributeType#STRING}, {@link AttributeType#LONG}, {@link
23+
* AttributeType#DOUBLE}, {@link AttributeType#BOOLEAN}, {@link AttributeType#STRING_ARRAY},
24+
* {@link AttributeType#LONG_ARRAY}, {@link AttributeType#DOUBLE_ARRAY}, {@link
25+
* AttributeType#BOOLEAN_ARRAY}) SHOULD be used whenever possible. Instrumentations SHOULD assume
26+
* that backends do not index individual properties of complex attributes, that querying or
27+
* aggregating on such properties is inefficient and complicated, and that reporting complex
28+
* attributes carries higher performance overhead.
2629
*/
2730
VALUE
2831
}

api/all/src/main/java/io/opentelemetry/api/common/Attributes.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ public interface Attributes {
3636
/**
3737
* Returns the value for the given {@link AttributeKey}, or {@code null} if not found.
3838
*
39-
* <p>Simple attributes (i.e. anything other than {@link Value} attributes) SHOULD be used
40-
* whenever possible. Instrumentations SHOULD assume that backends do not index individual
41-
* properties of complex attributes, that querying or aggregating on such properties is
42-
* inefficient and complicated, and that reporting complex attributes carries higher performance
43-
* overhead.
44-
*
45-
* <p>Note: when passing a key of type {@link AttributeType#VALUE}, the returned value will match
46-
* a narrower type with the given key if one exists. This is the inverse of {@link
39+
* <p>Note: this method will automatically convert simple attributes to complex attributes when
40+
* passed a key of type {@link AttributeType#VALUE}. This is the inverse of {@link
4741
* AttributesBuilder#put(AttributeKey, Object)} when the key is {@link AttributeType#VALUE}.
4842
*
4943
* <ul>
@@ -72,7 +66,12 @@ public interface Attributes {
7266
@Nullable
7367
<T> T get(AttributeKey<T> key);
7468

75-
/** Iterates over all the key-value pairs of attributes contained by this instance. */
69+
/**
70+
* Iterates over all the key-value pairs of attributes contained by this instance.
71+
*
72+
* <p>Note: {@link AttributeType#VALUE} attributes will be represented as simple attributes if
73+
* possible. See {@link AttributesBuilder#put(AttributeKey, Object)} for more details.
74+
*/
7675
void forEach(BiConsumer<? super AttributeKey<?>, ? super Object> consumer);
7776

7877
/** The number of attributes contained in this. */
@@ -81,7 +80,12 @@ public interface Attributes {
8180
/** Whether there are any attributes contained in this. */
8281
boolean isEmpty();
8382

84-
/** Returns a read-only view of this {@link Attributes} as a {@link Map}. */
83+
/**
84+
* Returns a read-only view of this {@link Attributes} as a {@link Map}.
85+
*
86+
* <p>Note: {@link AttributeType#VALUE} attributes will be represented as simple attributes in
87+
* this map if possible. See {@link AttributesBuilder#put(AttributeKey, Object)} for more details.
88+
*/
8589
Map<AttributeKey<?>, Object> asMap();
8690

8791
/** Returns a {@link Attributes} instance with no attributes. */

api/all/src/main/java/io/opentelemetry/api/common/AttributesBuilder.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ public interface AttributesBuilder {
4040
* Puts an {@link AttributeKey} with an associated value into this if the value is non-null.
4141
* Providing a null value does not remove or unset previously set values.
4242
*
43-
* <p>Note: when passing a key of type {@link AttributeType#VALUE}, the call will be coerced into
44-
* a narrower type if possible.
43+
* <p>Simple attributes ({@link AttributeType#STRING}, {@link AttributeType#LONG}, {@link
44+
* AttributeType#DOUBLE}, {@link AttributeType#BOOLEAN}, {@link AttributeType#STRING_ARRAY},
45+
* {@link AttributeType#LONG_ARRAY}, {@link AttributeType#DOUBLE_ARRAY}, {@link
46+
* AttributeType#BOOLEAN_ARRAY}) SHOULD be used whenever possible. Instrumentations SHOULD assume
47+
* that backends do not index individual properties of complex attributes, that querying or
48+
* aggregating on such properties is inefficient and complicated, and that reporting complex
49+
* attributes carries higher performance overhead.
50+
*
51+
* <p>Note: This method will automatically convert complex attributes ({@link
52+
* AttributeType#VALUE}) to simple attributes when possible.
4553
*
4654
* <ul>
4755
* <li>Calling {@code put(AttributeKey.valueKey("key"), Value.of("a"))} is equivalent to calling

0 commit comments

Comments
 (0)