Package zipkin2.reporter.okhttp3
Class OkHttpSender
- java.lang.Object
-
- zipkin2.Component
-
- zipkin2.reporter.Sender
-
- zipkin2.reporter.okhttp3.OkHttpSender
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public final class OkHttpSender extends Sender
Reports spans to Zipkin, using its POST endpoint.Usage
This type is designed forthe async reporter.Here's a simple configuration, configured for json:
sender = OkHttpSender.create("http://127.0.0.1:9411/api/v2/spans");Here's an example that adds basic auth (assuming you have an authenticating proxy):
{@code credential = Credentials.basic("me", "secure"); sender = OkHttpSender.newBuilder() .endpoint("https://authenticated-proxy/api/v2/spans") .clientBuilder().authenticator(new Authenticator() {
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOkHttpSender.Builder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description zipkin2.CheckResultcheck()Sends an empty json message to the configured endpoint.voidclose()Waits up to a second for in-flight requests to finish before cancelling themstatic OkHttpSendercreate(String endpoint)Creates a sender that postsEncoding.JSONmessages.zipkin2.codec.Encodingencoding()intmessageMaxBytes()intmessageSizeInBytes(int encodedSizeInBytes)intmessageSizeInBytes(List<byte[]> encodedSpans)static OkHttpSender.BuildernewBuilder()zipkin2.Call<Void>sendSpans(List<byte[]> encodedSpans)The returned call sends spans as a POST toOkHttpSender.Builder.endpoint(String).OkHttpSender.BuildertoBuilder()Creates a builder out of this object.StringtoString()
-
-
-
Method Detail
-
create
public static OkHttpSender create(String endpoint)
Creates a sender that postsEncoding.JSONmessages.
-
newBuilder
public static OkHttpSender.Builder newBuilder()
-
toBuilder
public final OkHttpSender.Builder toBuilder()
Creates a builder out of this object. Note: if theOkHttpSender.Builder.clientBuilder()was customized, you'll need to re-apply those customizations.
-
messageSizeInBytes
public int messageSizeInBytes(List<byte[]> encodedSpans)
- Specified by:
messageSizeInBytesin classSender
-
messageSizeInBytes
public int messageSizeInBytes(int encodedSizeInBytes)
- Overrides:
messageSizeInBytesin classSender
-
messageMaxBytes
public int messageMaxBytes()
- Specified by:
messageMaxBytesin classSender
-
sendSpans
public zipkin2.Call<Void> sendSpans(List<byte[]> encodedSpans)
The returned call sends spans as a POST toOkHttpSender.Builder.endpoint(String).
-
check
public zipkin2.CheckResult check()
Sends an empty json message to the configured endpoint.- Overrides:
checkin classzipkin2.Component
-
close
public void close()
Waits up to a second for in-flight requests to finish before cancelling them- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classzipkin2.Component
-
-