Class 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 Detail

      • 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 Detail

      • MarshalerUtil

        private MarshalerUtil()
    • 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.

      • 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.
      • 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.