Package zipkin2.reporter
Class BaseHttpSender<U,B>
- java.lang.Object
-
- zipkin2.reporter.BytesMessageSender.Base
-
- zipkin2.reporter.BaseHttpSender<U,B>
-
- Type Parameters:
U- The URL type for the HTTP client, such as URL or URI.B- The POST body, such asbyte[]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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface zipkin2.reporter.BytesMessageSender
BytesMessageSender.Base
-
-
Field Summary
-
Fields inherited from class zipkin2.reporter.BytesMessageSender.Base
encoding
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBaseHttpSender(Encoding encoding, HttpEndpointSupplier.Factory endpointSupplierFactory, String endpoint)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()protected voiddoClose()Override to close any resources.intmessageMaxBytes()Defaults to the most common max message size: 512KB.protected abstract BnewBody(List<byte[]> encodedSpans)Creates a new POST body from the encoded spans.protected abstract UnewEndpoint(String endpoint)Called each invocation of postSpans(Object, Object), unless the HttpEndpointSupplier is a HttpEndpointSupplier.Constant, Implementations should perform any validation needed here.protected abstract voidpostSpans(U endpoint, B body)Implement to POST spans to the given endpoint.voidsend(List<byte[]> encodedSpans)Sends spans as an HTTP POST request.StringtoString()-
Methods inherited from class zipkin2.reporter.BytesMessageSender.Base
encoding, messageSizeInBytes, messageSizeInBytes
-
-
-
-
Constructor Detail
-
BaseHttpSender
protected BaseHttpSender(Encoding encoding, HttpEndpointSupplier.Factory endpointSupplierFactory, String endpoint)
-
-
Method Detail
-
newEndpoint
protected abstract U newEndpoint(String endpoint)
Called each invocation of postSpans(Object, Object), unless the HttpEndpointSupplier is a HttpEndpointSupplier.Constant, Implementations should perform any validation needed here.- Since:
- 3.3
-
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()
-
-