Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;

@SuppressWarnings("deprecation")
@Immutable
final class ArrayBackedExtendedAttributes
extends ImmutableKeyValuePairs<ExtendedAttributeKey<?>, Object> implements ExtendedAttributes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@

package io.opentelemetry.api.incubator.common;

import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.booleanArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.booleanKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.doubleArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.doubleKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.longArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.longKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.stringArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.stringKey;

import io.opentelemetry.api.common.Value;
import io.opentelemetry.api.common.ValueType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

@SuppressWarnings("deprecation")
class ArrayBackedExtendedAttributesBuilder implements ExtendedAttributesBuilder {
private final List<Object> data;

Expand Down Expand Up @@ -62,16 +54,16 @@ private void putValue(ExtendedAttributeKey<?> key, Value<?> valueObj) {
String keyName = key.getKey();
switch (valueObj.getType()) {
case STRING:
put(stringKey(keyName), ((Value<String>) valueObj).getValue());
put(ExtendedAttributeKey.stringKey(keyName), ((Value<String>) valueObj).getValue());
return;
case LONG:
put(longKey(keyName), ((Value<Long>) valueObj).getValue());
put(ExtendedAttributeKey.longKey(keyName), ((Value<Long>) valueObj).getValue());
return;
case DOUBLE:
put(doubleKey(keyName), ((Value<Double>) valueObj).getValue());
put(ExtendedAttributeKey.doubleKey(keyName), ((Value<Double>) valueObj).getValue());
return;
case BOOLEAN:
put(booleanKey(keyName), ((Value<Boolean>) valueObj).getValue());
put(ExtendedAttributeKey.booleanKey(keyName), ((Value<Boolean>) valueObj).getValue());
return;
case ARRAY:
List<Value<?>> arrayValues = (List<Value<?>>) valueObj.getValue();
Expand All @@ -82,28 +74,28 @@ private void putValue(ExtendedAttributeKey<?> key, Value<?> valueObj) {
for (Value<?> v : arrayValues) {
strings.add((String) v.getValue());
}
put(stringArrayKey(keyName), strings);
put(ExtendedAttributeKey.stringArrayKey(keyName), strings);
return;
case LONG_ARRAY:
List<Long> longs = new ArrayList<>(arrayValues.size());
for (Value<?> v : arrayValues) {
longs.add((Long) v.getValue());
}
put(longArrayKey(keyName), longs);
put(ExtendedAttributeKey.longArrayKey(keyName), longs);
return;
case DOUBLE_ARRAY:
List<Double> doubles = new ArrayList<>(arrayValues.size());
for (Value<?> v : arrayValues) {
doubles.add((Double) v.getValue());
}
put(doubleArrayKey(keyName), doubles);
put(ExtendedAttributeKey.doubleArrayKey(keyName), doubles);
return;
case BOOLEAN_ARRAY:
List<Boolean> booleans = new ArrayList<>(arrayValues.size());
for (Value<?> v : arrayValues) {
booleans.add((Boolean) v.getValue());
}
put(booleanArrayKey(keyName), booleans);
put(ExtendedAttributeKey.booleanArrayKey(keyName), booleans);
return;
case VALUE:
// Not coercible (empty, non-homogeneous, or unsupported element type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
* </ul>
*
* @param <T> The type of value that can be set with the key.
* @deprecated Use {@link AttributeKey} with {@link AttributeKey#valueKey(String)} instead.
*/
@Deprecated
@Immutable
public interface ExtendedAttributeKey<T> {
/** Returns the underlying String representation of the key. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
* hence the types of values that are allowed for {@link ExtendedAttributes}.
*
* <p>This is a superset of {@link io.opentelemetry.api.common.AttributeType},
*
* @deprecated Use {@link io.opentelemetry.api.common.AttributeType} instead.
*/
@Deprecated
public enum ExtendedAttributeType {
// Types copied AttributeType
STRING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@
* {@link ExtendedAttributes}
* <li>{@link #get(AttributeKey)} supports reading values using standard {@link AttributeKey}
* </ul>
*
* @deprecated Use {@link Attributes} with {@link
* io.opentelemetry.api.common.AttributeKey#valueKey(String)} instead.
*/
@Deprecated
@Immutable
public interface ExtendedAttributes {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,20 @@

package io.opentelemetry.api.incubator.common;

import static io.opentelemetry.api.incubator.common.ArrayBackedExtendedAttributesBuilder.toList;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.booleanArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.booleanKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.doubleArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.doubleKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.longArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.longKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.stringArrayKey;
import static io.opentelemetry.api.incubator.common.ExtendedAttributeKey.stringKey;

import io.opentelemetry.api.common.AttributeKey;
import io.opentelemetry.api.common.Attributes;
import io.opentelemetry.api.common.Value;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

/** A builder of {@link ExtendedAttributes} supporting an arbitrary number of key-value pairs. */
/**
* A builder of {@link ExtendedAttributes} supporting an arbitrary number of key-value pairs.
*
* @deprecated Use {@link io.opentelemetry.api.common.AttributesBuilder} with {@link
* io.opentelemetry.api.common.AttributeKey#valueKey(String)} instead.
*/
@Deprecated
public interface ExtendedAttributesBuilder {
/** Create the {@link ExtendedAttributes} from this. */
ExtendedAttributes build();
Expand Down Expand Up @@ -85,7 +81,7 @@ default <T> ExtendedAttributesBuilder put(AttributeKey<T> key, T value) {
* @return this Builder
*/
default ExtendedAttributesBuilder put(String key, String value) {
return put(stringKey(key), value);
return put(ExtendedAttributeKey.stringKey(key), value);
}

/**
Expand All @@ -97,7 +93,7 @@ default ExtendedAttributesBuilder put(String key, String value) {
* @return this Builder
*/
default ExtendedAttributesBuilder put(String key, long value) {
return put(longKey(key), value);
return put(ExtendedAttributeKey.longKey(key), value);
}

/**
Expand All @@ -109,7 +105,7 @@ default ExtendedAttributesBuilder put(String key, long value) {
* @return this Builder
*/
default ExtendedAttributesBuilder put(String key, double value) {
return put(doubleKey(key), value);
return put(ExtendedAttributeKey.doubleKey(key), value);
}

/**
Expand All @@ -121,7 +117,7 @@ default ExtendedAttributesBuilder put(String key, double value) {
* @return this Builder
*/
default ExtendedAttributesBuilder put(String key, boolean value) {
return put(booleanKey(key), value);
return put(ExtendedAttributeKey.booleanKey(key), value);
}

/**
Expand Down Expand Up @@ -151,7 +147,7 @@ default ExtendedAttributesBuilder put(String key, String... value) {
if (value == null) {
return this;
}
return put(stringArrayKey(key), Arrays.asList(value));
return put(ExtendedAttributeKey.stringArrayKey(key), Arrays.asList(value));
}

/**
Expand Down Expand Up @@ -179,7 +175,8 @@ default ExtendedAttributesBuilder put(String key, long... value) {
if (value == null) {
return this;
}
return put(longArrayKey(key), toList(value));
return put(
ExtendedAttributeKey.longArrayKey(key), ArrayBackedExtendedAttributesBuilder.toList(value));
}

/**
Expand All @@ -194,7 +191,9 @@ default ExtendedAttributesBuilder put(String key, double... value) {
if (value == null) {
return this;
}
return put(doubleArrayKey(key), toList(value));
return put(
ExtendedAttributeKey.doubleArrayKey(key),
ArrayBackedExtendedAttributesBuilder.toList(value));
}

/**
Expand All @@ -209,7 +208,9 @@ default ExtendedAttributesBuilder put(String key, boolean... value) {
if (value == null) {
return this;
}
return put(booleanArrayKey(key), toList(value));
return put(
ExtendedAttributeKey.booleanArrayKey(key),
ArrayBackedExtendedAttributesBuilder.toList(value));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* This class is internal and is hence not for public use. Its APIs are unstable and can change at
* any time.
*/
@SuppressWarnings("deprecation")
public final class InternalExtendedAttributeKeyImpl<T> implements ExtendedAttributeKey<T> {

private final ExtendedAttributeType type;
Expand Down Expand Up @@ -115,7 +116,6 @@ private static int buildHashCode(ExtendedAttributeType type, String key) {
* io.opentelemetry.api.common.AttributeType}.
*/
@Nullable
@SuppressWarnings("deprecation") // Supporting deprecated EXTENDED_ATTRIBUTES until removed
public static <T> AttributeKey<T> toAttributeKey(ExtendedAttributeKey<T> extendedAttributeKey) {
switch (extendedAttributeKey.getType()) {
case STRING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

@SuppressWarnings("deprecation")
class ExtendedDefaultLogger implements ExtendedLogger {

private static final Logger INSTANCE = new ExtendedDefaultLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import javax.annotation.Nullable;

/** Extended {@link LogRecordBuilder} with experimental APIs. */
@SuppressWarnings("deprecation")
public interface ExtendedLogRecordBuilder extends LogRecordBuilder {

// keep this class even if it is empty, since experimental methods may be added in the future.
Expand Down
Loading
Loading