Skip to content

Commit 4ee9076

Browse files
committed
Deprecation
1 parent 8345dba commit 4ee9076

File tree

10 files changed

+29
-6
lines changed

10 files changed

+29
-6
lines changed

api/incubator/src/main/java/io/opentelemetry/api/incubator/common/ExtendedAttributeKey.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ static ExtendedAttributeKey<List<Double>> doubleArrayKey(String key) {
9494
return fromAttributeKey(AttributeKey.doubleArrayKey(key));
9595
}
9696

97-
/** Returns a new ExtendedAttributeKey for Map valued attributes. */
97+
/**
98+
* Returns a new ExtendedAttributeKey for {@link ExtendedAttributes} valued attributes.
99+
*
100+
* @deprecated Use {@link #valueKey(String)} in combination with {@link Value#of(java.util.Map)}
101+
* instead.
102+
*/
103+
@Deprecated
104+
@SuppressWarnings("deprecation")
98105
static ExtendedAttributeKey<ExtendedAttributes> extendedAttributesKey(String key) {
99106
return InternalExtendedAttributeKeyImpl.create(key, ExtendedAttributeType.EXTENDED_ATTRIBUTES);
100107
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/common/ExtendedAttributeType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public enum ExtendedAttributeType {
2222
LONG_ARRAY,
2323
DOUBLE_ARRAY,
2424
// Extended types unique to ExtendedAttributes
25+
/**
26+
* @deprecated Use {@link #VALUE} with {@link io.opentelemetry.api.common.Value}-based maps
27+
* instead.
28+
*/
29+
@Deprecated
2530
EXTENDED_ATTRIBUTES,
2631
VALUE;
2732
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/common/ExtendedAttributes.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
*
1919
* <p>"extended" refers an extended set of allowed value types compared to standard {@link
2020
* Attributes}. Notably, {@link ExtendedAttributes} values can be of type {@link
21+
* ExtendedAttributeType#VALUE}, allowing attributes backed by {@link
22+
* io.opentelemetry.api.common.Value}, and the deprecated {@link
2123
* ExtendedAttributeType#EXTENDED_ATTRIBUTES}, allowing nested {@link ExtendedAttributes} of
22-
* arbitrary depth, and {@link ExtendedAttributeType#VALUE}, allowing attributes backed by {@link
23-
* io.opentelemetry.api.common.Value}.
24+
* arbitrary depth.
2425
*
2526
* <p>Where standard {@link Attributes} are accepted everyone that OpenTelemetry represents key /
2627
* value pairs, {@link ExtendedAttributes} are only accepted in select places, such as log records

api/incubator/src/main/java/io/opentelemetry/api/incubator/common/ExtendedAttributesBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,11 @@ default ExtendedAttributesBuilder put(String key, boolean value) {
9393
* <p>Note: It is strongly recommended to use {@link #put(ExtendedAttributeKey, Object)}, and
9494
* pre-allocate your keys, if possible.
9595
*
96+
* @deprecated Use {@link #put(String, Value)} with {@link Value#of(java.util.Map)} instead.
9697
* @return this Builder
9798
*/
99+
@Deprecated
100+
@SuppressWarnings("deprecation")
98101
default <T> ExtendedAttributesBuilder put(String key, ExtendedAttributes value) {
99102
return put(ExtendedAttributeKey.extendedAttributesKey(key), value);
100103
}

api/incubator/src/main/java/io/opentelemetry/api/incubator/internal/InternalExtendedAttributeKeyImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ private static int buildHashCode(ExtendedAttributeType type, String key) {
115115
* io.opentelemetry.api.common.AttributeType}.
116116
*/
117117
@Nullable
118+
@SuppressWarnings("deprecation") // Supporting deprecated EXTENDED_ATTRIBUTES until removed
118119
public static <T> AttributeKey<T> toAttributeKey(ExtendedAttributeKey<T> extendedAttributeKey) {
119120
switch (extendedAttributeKey.getType()) {
120121
case STRING:

api/incubator/src/test/java/io/opentelemetry/api/incubator/common/ExtendedAttributeKeyTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.junit.jupiter.params.provider.Arguments;
1515
import org.junit.jupiter.params.provider.MethodSource;
1616

17+
@SuppressWarnings("deprecation") // Testing deprecated EXTENDED_ATTRIBUTES until removed
1718
public class ExtendedAttributeKeyTest {
1819

1920
@ParameterizedTest

api/incubator/src/test/java/io/opentelemetry/api/incubator/common/ExtendedAttributesTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.junit.jupiter.params.provider.Arguments;
2222
import org.junit.jupiter.params.provider.MethodSource;
2323

24+
@SuppressWarnings("deprecation") // Testing deprecated EXTENDED_ATTRIBUTES until removed
2425
class ExtendedAttributesTest {
2526

2627
@ParameterizedTest

api/incubator/src/test/java/io/opentelemetry/api/incubator/logs/ExtendedLogsBridgeApiUsageTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ private static String flipCoin() {
104104
AttributeKey<List<Double>> doubleArrKey = AttributeKey.doubleArrayKey("acme.double_array");
105105

106106
// Extended keys
107+
@SuppressWarnings("deprecation") // Supporting deprecated EXTENDED_ATTRIBUTES until removed
107108
ExtendedAttributeKey<ExtendedAttributes> mapKey =
108109
ExtendedAttributeKey.extendedAttributesKey("acme.map");
109110

exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/ExtendedAttributeKeyValueStatelessMarshaler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ private static class ValueStatelessMarshaler
141141
implements StatelessMarshaler2<ExtendedAttributeKey<?>, Object> {
142142
static final ValueStatelessMarshaler INSTANCE = new ValueStatelessMarshaler();
143143

144-
@SuppressWarnings("unchecked")
144+
// Supporting deprecated EXTENDED_ATTRIBUTES type until removed
145+
@SuppressWarnings({"unchecked", "deprecation"})
145146
@Override
146147
public int getBinarySerializedSize(
147148
ExtendedAttributeKey<?> attributeKey, Object value, MarshalerContext context) {
@@ -184,7 +185,8 @@ public int getBinarySerializedSize(
184185
throw new IllegalArgumentException("Unsupported attribute type.");
185186
}
186187

187-
@SuppressWarnings("unchecked")
188+
// Supporting deprecated EXTENDED_ATTRIBUTES type until removed
189+
@SuppressWarnings({"unchecked", "deprecation"})
188190
@Override
189191
public void writeTo(
190192
Serializer output,

exporters/otlp/common/src/main/java/io/opentelemetry/exporter/internal/otlp/IncubatingUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public void accept(ExtendedAttributeKey<?> attributeKey, Object o) {
8181
}
8282

8383
// TODO(jack-berg): move to KeyValueMarshaler when ExtendedAttributes is stable
84-
@SuppressWarnings("unchecked")
84+
// Supporting deprecated EXTENDED_ATTRIBUTES type until removed
85+
@SuppressWarnings({"unchecked", "deprecation"})
8586
private static KeyValueMarshaler create(ExtendedAttributeKey<?> attributeKey, Object value) {
8687
byte[] keyUtf8;
8788
if (attributeKey.getKey().isEmpty()) {

0 commit comments

Comments
 (0)