Class BaseHttpSender<U,​B>

  • Type Parameters:
    U - The URL type for the HTTP client, such as URL or URI.
    B - The POST body, such as byte[] or an HTTP client-specific body type.
    All Implemented Interfaces:
    Closeable, BytesMessageSender

    public abstract class BaseHttpSender<U,​B>
    extends BytesMessageSender.Base
    Reports spans to Zipkin, using its POST endpoint.

    Calls to postSpans(Object, Object) happen on the same async reporting thread, but close() might be called from any thread.

    Since:
    3.3
    • Method Detail

      • newBody

        protected abstract B newBody​(List<byte[]> encodedSpans)
                              throws IOException
        Creates a new POST body from the encoded spans.

        Below is the simplest implementation, when {@linkplain BaseHttpSender#} is a byte array.

        {@code
        Throws:
        IOException
        Since:
        3.3
      • postSpans

        protected abstract void postSpans​(U endpoint,
                                          B body)
                                   throws IOException
        Implement to POST spans to the given endpoint.

        If you need the "Content-Type" value, you can access it via Encoding.mediaType().

        Throws:
        IOException
        Since:
        3.3
      • doClose

        protected void doClose()
        Override to close any resources.
        Since:
        3.3
      • messageMaxBytes

        public int messageMaxBytes()
        Defaults to the most common max message size: 512KB.
      • send

        public final void send​(List<byte[]> encodedSpans)
                        throws IOException
        Sends spans as an HTTP POST request.
        Parameters:
        encodedSpans - a potentially empty list of encoded spans.
        Throws:
        IOException
      • close

        public final void close()