File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed
api/all/src/main/java/io/opentelemetry/api Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,15 @@ public interface AttributesBuilder {
3535 // version.
3636 <T > AttributesBuilder put (AttributeKey <Long > key , int value );
3737
38- /** Puts a {@link AttributeKey} with associated value into this. */
38+ /**
39+ * Puts an {@link AttributeKey} with an associated value into this if the value is non-null.
40+ * Providing a null value does not remove or unset previously set values.
41+ */
3942 <T > AttributesBuilder put (AttributeKey <T > key , T value );
4043
4144 /**
42- * Puts a String attribute into this.
45+ * Puts a String attribute into this if the value is non-null. Providing a null value does not
46+ * remove or unset previously set values.
4347 *
4448 * <p>Note: It is strongly recommended to use {@link #put(AttributeKey, Object)}, and pre-allocate
4549 * your keys, if possible.
Original file line number Diff line number Diff line change @@ -107,6 +107,8 @@ default LogRecordBuilder setAllAttributes(Attributes attributes) {
107107 * Sets an attribute on the {@code LogRecord}. If the {@code LogRecord} previously contained a
108108 * mapping for the key, the old value is replaced by the specified value.
109109 *
110+ * <p>Note: Providing a null value is a no-op and will not remove previously set values.
111+ *
110112 * @param key the key for this attribute.
111113 * @param value the value for this attribute.
112114 * @return this.
@@ -117,6 +119,8 @@ default LogRecordBuilder setAllAttributes(Attributes attributes) {
117119 * Sets a String attribute on the {@code LogRecord}. If the {@code LogRecord} previously contained
118120 * a mapping for the key, the old value is replaced by the specified value.
119121 *
122+ * <p>Note: Providing a null value is a no-op and will not remove previously set values.
123+ *
120124 * <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
121125 * pre-allocate your keys, if possible.
122126 *
Original file line number Diff line number Diff line change @@ -88,7 +88,9 @@ static Span wrap(SpanContext spanContext) {
8888 * Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
8989 * the key, the old value is replaced by the specified value.
9090 *
91- * <p>Empty String "" and null are valid attribute {@code value}, but not valid keys.
91+ * <p>Empty String "" and null are valid attribute {@code value}s, but not valid keys.
92+ *
93+ * <p>Note: Providing a null value is a no-op and will not remove previously set values.
9294 *
9395 * <p>Note: It is strongly recommended to use {@link #setAttribute(AttributeKey, Object)}, and
9496 * pre-allocate your keys, if possible.
@@ -150,7 +152,7 @@ default Span setAttribute(String key, boolean value) {
150152 * Sets an attribute to the {@code Span}. If the {@code Span} previously contained a mapping for
151153 * the key, the old value is replaced by the specified value.
152154 *
153- * <p>Note: the behavior of null values is undefined, and hence strongly discouraged .
155+ * <p>Note: Providing a null value is a no-op .
154156 *
155157 * @param key the key for this attribute.
156158 * @param value the value for this attribute.
You can’t perform that action at this time.
0 commit comments