Class MarshalerUtil

java.lang.Object
io.opentelemetry.exporter.internal.marshal.MarshalerUtil

public final class MarshalerUtil extends 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 Details

    • TRACE_ID_VALUE_SIZE

      private static final int TRACE_ID_VALUE_SIZE
    • SPAN_ID_VALUE_SIZE

      private static final int SPAN_ID_VALUE_SIZE
    • JSON_AVAILABLE

      private static final boolean JSON_AVAILABLE
    • EMPTY_BYTES

      private static final byte[] EMPTY_BYTES
  • Constructor Details

    • MarshalerUtil

      private MarshalerUtil()
  • Method Details

    • groupByResourceAndScope

      public static <T, U> Map<Resource,Map<InstrumentationScopeInfo,List<U>>> groupByResourceAndScope(Collection<T> dataList, Function<T,Resource> getResource, Function<T,InstrumentationScopeInfo> getInstrumentationScope, Function<T,U> createMarshaler)
      Groups SDK items by resource and instrumentation scope.
    • preserializeJsonFields

      public static String preserializeJsonFields(Marshaler marshaler)
      Preserialize into JSON format.
    • sizeRepeatedFixed64

      public static int sizeRepeatedFixed64(ProtoFieldInfo field, List<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, List<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 uses DynamicPrimitiveLongList 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, List<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, List<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, 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, 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 String traceId)
      Returns the size of a trace_id field.
    • sizeSpanId

      public static int sizeSpanId(ProtoFieldInfo field, @Nullable String spanId)
      Returns the size of a span_id field.
    • toBytes

      public static byte[] toBytes(@Nullable String value)
      Converts the string to utf8 bytes for encoding.