Skip to content

Commit 5cfe4ab

Browse files
committed
more javadoc
1 parent fa87c47 commit 5cfe4ab

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ public enum AttributeType {
1818
BOOLEAN_ARRAY,
1919
LONG_ARRAY,
2020
DOUBLE_ARRAY,
21+
/**
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.
26+
*/
2127
VALUE
2228
}

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,42 @@
3333
@Immutable
3434
public interface Attributes {
3535

36-
/** Returns the value for the given {@link AttributeKey}, or {@code null} if not found. */
36+
/**
37+
* Returns the value for the given {@link AttributeKey}, or {@code null} if not found.
38+
*
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
47+
* AttributesBuilder#put(AttributeKey, Object)} when the key is {@link AttributeType#VALUE}.
48+
*
49+
* <ul>
50+
* <li>If {@code put(AttributeKey.stringKey("key"), "a")} was called, then {@code
51+
* get(AttributeKey.valueKey("key"))} returns {@code Value.of("a")}.
52+
* <li>If {@code put(AttributeKey.longKey("key"), 1L)} was called, then {@code
53+
* get(AttributeKey.valueKey("key"))} returns {@code Value.of(1L)}.
54+
* <li>If {@code put(AttributeKey.doubleKey("key"), 1.0)} was called, then {@code
55+
* get(AttributeKey.valueKey("key"))} returns {@code Value.of(1.0)}.
56+
* <li>If {@code put(AttributeKey.booleanKey("key"), true)} was called, then {@code
57+
* get(AttributeKey.valueKey("key"))} returns {@code Value.of(true)}.
58+
* <li>If {@code put(AttributeKey.stringArrayKey("key"), Arrays.asList("a", "b"))} was called,
59+
* then {@code get(AttributeKey.valueKey("key"))} returns {@code Value.of(Value.of("a"),
60+
* Value.of("b"))}.
61+
* <li>If {@code put(AttributeKey.longArrayKey("key"), Arrays.asList(1L, 2L))} was called, then
62+
* {@code get(AttributeKey.valueKey("key"))} returns {@code Value.of(Value.of(1L),
63+
* Value.of(2L))}.
64+
* <li>If {@code put(AttributeKey.doubleArrayKey("key"), Arrays.asList(1.0, 2.0))} was called,
65+
* then {@code get(AttributeKey.valueKey("key"))} returns {@code Value.of(Value.of(1.0),
66+
* Value.of(2.0))}.
67+
* <li>If {@code put(AttributeKey.booleanArrayKey("key"), Arrays.asList(true, false))} was
68+
* called, then {@code get(AttributeKey.valueKey("key"))} returns {@code
69+
* Value.of(Value.of(true), Value.of(false))}.
70+
* </ul>
71+
*/
3772
@Nullable
3873
<T> T get(AttributeKey<T> key);
3974

0 commit comments

Comments
 (0)