Top Description Methods
io.opentelemetry.api.common

public Interface Value<T>

Known Direct Implementers
io.opentelemetry.api.common.ValueArray, io.opentelemetry.api.common.ValueBoolean, io.opentelemetry.api.common.ValueBytes, io.opentelemetry.api.common.ValueDouble, io.opentelemetry.api.common.ValueLong, io.opentelemetry.api.common.ValueString, io.opentelemetry.api.common.KeyValueList
Type Parameters
<T>
the type. See getValue() for description of types.
Imports
java.nio.ByteBuffer, java.util.List, .Map

Value mirrors the proto AnyValue message type, and is used to model any type.

It can be used to represent:

Currently, Value is only used as an argument for io.opentelemetry.api.logs.LogRecordBuilder#setBody(Value).

Since
1.42.0

Method Summary

Modifier and TypeMethod and Description
public String
asString()

Return a string encoding of this Value.

public ValueType
getType()

Returns the type of this Value.

public T
getValue()

Returns the value for this Value.

public static Value<String>
of(String value)

Returns an Value for the String value.

public static Value<Boolean>
of(boolean value)

Returns an Value for the boolean value.

public static Value<Long>
of(long value)

Returns an Value for the long value.

public static Value<Double>
of(double value)

Returns an Value for the double value.

public static Value<ByteBuffer>
of(byte[] value)

Returns an Value for the byte[] value.

public static Value<List<Value<?>>>
of(Value<?>... value)

Returns an Value for the array of Value values.

public static Value<List<Value<?>>>
of(List<Value<?>> value)

Returns an Value for the list of Value values.

public static Value<List<KeyValue>>
of(KeyValue... value)

Returns an Value for the array of KeyValue values.

public static Value<List<KeyValue>>
of(Map<String, Value<?>> value)

Returns an Value for the Map of key, Value.

Method Detail

asStringback to summary
public String asString()

Return a string encoding of this Value. This is intended to be a fallback serialized representation in case there is no suitable encoding that can utilize getType() / getValue() to serialize specific types.

Warning

No guarantees are made about the encoding of this string response. It MAY change in a future minor release. If you need a reliable string encoding, write your own serializer.

getTypeback to summary
public ValueType getType()

Returns the type of this Value. Useful for building switch statements.

getValueback to summary
public T getValue()

Returns the value for this Value.

The return type varies by getType() as described below:

ofback to summary
public static Value<String> of(String value)

Returns an Value for the String value.

ofback to summary
public static Value<Boolean> of(boolean value)

Returns an Value for the boolean value.

ofback to summary
public static Value<Long> of(long value)

Returns an Value for the long value.

ofback to summary
public static Value<Double> of(double value)

Returns an Value for the double value.

ofback to summary
public static Value<ByteBuffer> of(byte[] value)

Returns an Value for the byte[] value.

ofback to summary
public static Value<List<Value<?>>> of(Value<?>... value)

Returns an Value for the array of Value values.

ofback to summary
public static Value<List<Value<?>>> of(List<Value<?>> value)

Returns an Value for the list of Value values.

ofback to summary
public static Value<List<KeyValue>> of(KeyValue... value)

Returns an Value for the array of KeyValue values. KeyValue#getKey() values should not repeat - duplicates may be dropped.

ofback to summary
public static Value<List<KeyValue>> of(Map<String, Value<?>> value)

Returns an Value for the Map of key, Value.