Class DslJsonSerializer

    • Field Detail

      • BUFFER_SIZE

        public static final int BUFFER_SIZE
        Matches default ZLIB buffer size. Lets us assume the ZLIB buffer is always empty, so that getBufferSize() is the total amount of buffered bytes.
        See Also:
        Constant Field Values
      • MAX_LONG_STRING_VALUE_LENGTH

        public static final int MAX_LONG_STRING_VALUE_LENGTH
        See Also:
        Constant Field Values
    • Method Detail

      • setOutputStream

        public void setOutputStream​(java.io.OutputStream os)
        Description copied from interface: PayloadSerializer
        Sets the output stream which the *NdJson methods should write to.
        Specified by:
        setOutputStream in interface PayloadSerializer
        Parameters:
        os - the OutputStream to which all contents are to be serialized
      • fullFlush

        public void fullFlush()
                       throws java.io.IOException
        Flushes the OutputStream which has been set via setOutputStream(OutputStream) and detaches that OutputStream from the serializer.
        Specified by:
        fullFlush in interface PayloadSerializer
        Throws:
        java.io.IOException
      • flushToOutputStream

        public void flushToOutputStream()
        Flushes content that has been written so far to the OutputStream which has been set via setOutputStream(OutputStream), without flushing the OutputStream itself. Subsequent serializations will be made to the same OutputStream.
        Specified by:
        flushToOutputStream in interface PayloadSerializer
      • blockUntilReady

        public void blockUntilReady()
                             throws java.lang.Exception
        Blocking until this PayloadSerializer is ready for use. Blocking will be timed out with a TimeoutException if the serializer is not ready within 5 seconds. Since the requirement is to call this method is called on the same thread that calls subsequently calls appendMetadataToStream(), there is no risk of visibility issues with regard to serializedMetaData.
        Specified by:
        blockUntilReady in interface PayloadSerializer
        Throws:
        java.lang.Exception - if blocking was interrupted, or timed out or an error occurred in the underlying implementation
      • getBufferSize

        public int getBufferSize()
        Returns the number of bytes already serialized and waiting in the underlying JsonWriter's buffer. Note that the resulting JSON can be bigger if a Stream is set to the writer and some data was already flushed
        Specified by:
        getBufferSize in interface PayloadSerializer
        Returns:
        number of bytes currently waiting in the underlying JsonWriter to be flushed to the underlying stream
      • toJsonString

        public java.lang.String toJsonString​(Transaction transaction)
      • toJsonString

        public java.lang.String toJsonString​(Span span)
      • toJsonString

        public java.lang.String toJsonString​(ErrorCapture error)
      • toJsonString

        public java.lang.String toJsonString​(java.lang.StackTraceElement stackTraceElement)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • sanitizeLabelKey

        public static java.lang.CharSequence sanitizeLabelKey​(java.lang.String key,
                                                              java.lang.StringBuilder replaceBuilder)
      • writeStringValue

        public static void writeStringValue​(java.lang.CharSequence value,
                                            java.lang.StringBuilder replaceBuilder,
                                            com.dslplatform.json.JsonWriter jw)
      • writeLastField

        public static void writeLastField​(java.lang.String fieldName,
                                          @Nullable
                                          java.lang.CharSequence value,
                                          java.lang.StringBuilder replaceBuilder,
                                          com.dslplatform.json.JsonWriter jw)
      • writeFieldName

        public static void writeFieldName​(java.lang.String fieldName,
                                          com.dslplatform.json.JsonWriter jw)