Class MarshalerUtil
- java.lang.Object
-
- io.opentelemetry.exporter.internal.marshal.MarshalerUtil
-
public final class MarshalerUtil extends java.lang.Object
Marshaler utilities.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]
EMPTY_BYTES
private static boolean
JSON_AVAILABLE
private static int
SPAN_ID_VALUE_SIZE
private static int
TRACE_ID_VALUE_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description private
MarshalerUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U>
java.util.Map<Resource,java.util.Map<InstrumentationScopeInfo,java.util.List<U>>>groupByResourceAndScope(java.util.Collection<T> dataList, java.util.function.Function<T,Resource> getResource, java.util.function.Function<T,InstrumentationScopeInfo> getInstrumentationScope, java.util.function.Function<T,U> createMarshaler)
Groups SDK items by resource and instrumentation scope.static java.lang.String
preserializeJsonFields(Marshaler marshaler)
Preserialize into JSON format.static int
sizeBool(ProtoFieldInfo field, boolean value)
Returns the size of a bool field.static int
sizeByteAsFixed32(ProtoFieldInfo field, byte message)
Returns the size of a byte field when propagated to a fixed32.static int
sizeByteBuffer(ProtoFieldInfo field, java.nio.ByteBuffer message)
Returns the size of a bytes field based on the buffer's capacity.static int
sizeBytes(ProtoFieldInfo field, byte[] message)
Returns the size of a bytes field.static int
sizeDouble(ProtoFieldInfo field, double value)
Returns the size of a double field.static int
sizeDoubleOptional(ProtoFieldInfo field, double value)
Returns the size of a double field.static int
sizeEnum(ProtoFieldInfo field, ProtoEnumInfo enumValue)
Returns the size of a enum field.static int
sizeFixed32(ProtoFieldInfo field, int message)
Returns the size of a fixed32 field.static int
sizeFixed64(ProtoFieldInfo field, long value)
Returns the size of a fixed64 field.static int
sizeFixed64Optional(ProtoFieldInfo field, long value)
Returns the size of a fixed64 field.static int
sizeInt32(ProtoFieldInfo field, int message)
Returns the size of a int32 field.static int
sizeInt64(ProtoFieldInfo field, long message)
Returns the size of a int64 field.static int
sizeMessage(ProtoFieldInfo field, Marshaler message)
Returns the size of a message field.static int
sizeRepeatedDouble(ProtoFieldInfo field, java.util.List<java.lang.Double> values)
Returns the size of a repeated double field.private static int
sizeRepeatedFixed64(ProtoFieldInfo field, int numValues)
static int
sizeRepeatedFixed64(ProtoFieldInfo field, java.util.List<java.lang.Long> values)
Returns the size of a repeated fixed64 field.static int
sizeRepeatedInt64(ProtoFieldInfo field, long[] values)
Returns the size of a repeated int64 field.static int
sizeRepeatedInt64(ProtoFieldInfo field, java.util.List<java.lang.Long> values)
Returns the size of a repeated int64 field.static int
sizeRepeatedMessage(ProtoFieldInfo field, java.util.List<? extends Marshaler> repeatedMessage)
Returns the size of a repeated message field.static <T extends Marshaler>
intsizeRepeatedMessage(ProtoFieldInfo field, T[] repeatedMessage)
Returns the size of a repeated message field.static int
sizeRepeatedUInt64(ProtoFieldInfo field, long[] values)
Returns the size of a repeated uint64 field.static int
sizeRepeatedUInt64(ProtoFieldInfo field, DynamicPrimitiveLongList values)
Returns the size of a repeated uint64 field.static int
sizeRepeatedUInt64(ProtoFieldInfo field, java.util.List<java.lang.Long> values)
Returns the size of a repeated uint64 field.static int
sizeSInt32(ProtoFieldInfo field, int message)
Returns the size of a sint32 field.static int
sizeSpanId(ProtoFieldInfo field, java.lang.String spanId)
Returns the size of a span_id field.static int
sizeTraceId(ProtoFieldInfo field, java.lang.String traceId)
Returns the size of a trace_id field.static int
sizeUInt32(ProtoFieldInfo field, int message)
Returns the size of a uint32 field.static int
sizeUInt64(ProtoFieldInfo field, long message)
Returns the size of a uint64 field.static byte[]
toBytes(java.lang.String value)
Converts the string to utf8 bytes for encoding.
-
-
-
Method Detail
-
groupByResourceAndScope
public static <T,U> java.util.Map<Resource,java.util.Map<InstrumentationScopeInfo,java.util.List<U>>> groupByResourceAndScope(java.util.Collection<T> dataList, java.util.function.Function<T,Resource> getResource, java.util.function.Function<T,InstrumentationScopeInfo> getInstrumentationScope, java.util.function.Function<T,U> createMarshaler)
Groups SDK items by resource and instrumentation scope.
-
preserializeJsonFields
public static java.lang.String preserializeJsonFields(Marshaler marshaler)
Preserialize into JSON format.
-
sizeRepeatedFixed64
public static int sizeRepeatedFixed64(ProtoFieldInfo field, java.util.List<java.lang.Long> values)
Returns the size of a repeated fixed64 field.
-
sizeRepeatedFixed64
private static int sizeRepeatedFixed64(ProtoFieldInfo field, int numValues)
-
sizeRepeatedUInt64
public static int sizeRepeatedUInt64(ProtoFieldInfo field, long[] values)
Returns the size of a repeated uint64 field.Packed repeated fields contain the tag, an integer representing the incoming payload size, and an actual payload of repeated varints.
-
sizeRepeatedUInt64
public static int sizeRepeatedUInt64(ProtoFieldInfo field, java.util.List<java.lang.Long> values)
Returns the size of a repeated uint64 field.Packed repeated fields contain the tag, an integer representing the incoming payload size, and an actual payload of repeated varints.
-
sizeRepeatedUInt64
public static int sizeRepeatedUInt64(ProtoFieldInfo field, DynamicPrimitiveLongList values)
Returns the size of a repeated uint64 field.Packed repeated fields contain the tag, an integer representing the incoming payload size, and an actual payload of repeated varints.
NOTE: This method has the same logic as
sizeRepeatedUInt64(ProtoFieldInfo, long[])
)} but instead of using a primitive array it usesDynamicPrimitiveLongList
to avoid boxing/unboxing
-
sizeRepeatedInt64
public static int sizeRepeatedInt64(ProtoFieldInfo field, long[] values)
Returns the size of a repeated int64 field.Packed repeated fields contain the tag, an integer representing the incoming payload size, and an actual payload of repeated varints.
-
sizeRepeatedInt64
public static int sizeRepeatedInt64(ProtoFieldInfo field, java.util.List<java.lang.Long> values)
Returns the size of a repeated int64 field.Packed repeated fields contain the tag, an integer representing the incoming payload size, and an actual payload of repeated varints.
-
sizeRepeatedDouble
public static int sizeRepeatedDouble(ProtoFieldInfo field, java.util.List<java.lang.Double> values)
Returns the size of a repeated double field.
-
sizeRepeatedMessage
public static <T extends Marshaler> int sizeRepeatedMessage(ProtoFieldInfo field, T[] repeatedMessage)
Returns the size of a repeated message field.
-
sizeRepeatedMessage
public static int sizeRepeatedMessage(ProtoFieldInfo field, java.util.List<? extends Marshaler> repeatedMessage)
Returns the size of a repeated message field.
-
sizeMessage
public static int sizeMessage(ProtoFieldInfo field, Marshaler message)
Returns the size of a message field.
-
sizeBool
public static int sizeBool(ProtoFieldInfo field, boolean value)
Returns the size of a bool field.
-
sizeInt64
public static int sizeInt64(ProtoFieldInfo field, long message)
Returns the size of a int64 field.
-
sizeUInt64
public static int sizeUInt64(ProtoFieldInfo field, long message)
Returns the size of a uint64 field.
-
sizeUInt32
public static int sizeUInt32(ProtoFieldInfo field, int message)
Returns the size of a uint32 field.
-
sizeSInt32
public static int sizeSInt32(ProtoFieldInfo field, int message)
Returns the size of a sint32 field.
-
sizeInt32
public static int sizeInt32(ProtoFieldInfo field, int message)
Returns the size of a int32 field.
-
sizeDouble
public static int sizeDouble(ProtoFieldInfo field, double value)
Returns the size of a double field.
-
sizeDoubleOptional
public static int sizeDoubleOptional(ProtoFieldInfo field, double value)
Returns the size of a double field.
-
sizeFixed64
public static int sizeFixed64(ProtoFieldInfo field, long value)
Returns the size of a fixed64 field.
-
sizeFixed64Optional
public static int sizeFixed64Optional(ProtoFieldInfo field, long value)
Returns the size of a fixed64 field.
-
sizeByteAsFixed32
public static int sizeByteAsFixed32(ProtoFieldInfo field, byte message)
Returns the size of a byte field when propagated to a fixed32.
-
sizeFixed32
public static int sizeFixed32(ProtoFieldInfo field, int message)
Returns the size of a fixed32 field.
-
sizeBytes
public static int sizeBytes(ProtoFieldInfo field, byte[] message)
Returns the size of a bytes field.
-
sizeByteBuffer
public static int sizeByteBuffer(ProtoFieldInfo field, java.nio.ByteBuffer message)
Returns the size of a bytes field based on the buffer's capacity.
-
sizeEnum
public static int sizeEnum(ProtoFieldInfo field, ProtoEnumInfo enumValue)
Returns the size of a enum field.
-
sizeTraceId
public static int sizeTraceId(ProtoFieldInfo field, @Nullable java.lang.String traceId)
Returns the size of a trace_id field.
-
sizeSpanId
public static int sizeSpanId(ProtoFieldInfo field, @Nullable java.lang.String spanId)
Returns the size of a span_id field.
-
toBytes
public static byte[] toBytes(@Nullable java.lang.String value)
Converts the string to utf8 bytes for encoding.
-
-