public static BytesMessageEncoder forEncoding(Encoding encoding) { if (encoding == null) throw new NullPointerException("encoding == null"); switch (encoding) { case JSON: return JSON; case THRIFT: return THRIFT; default: throw new UnsupportedOperationException(encoding.name()); } } }
/** Builds an async reporter that encodes zipkin v2 spans as they are reported. */ public AsyncReporter<zipkin2.Span> buildV2() { switch (sender.encoding()) { case JSON: return build(SpanEncoder.JSON_V2); default: throw new UnsupportedOperationException(sender.encoding().name()); } }
/** Builds an async reporter that encodes zipkin spans as they are reported. */ public AsyncReporter<Span> build() { switch (sender.encoding()) { case JSON: return build(Encoder.JSON); case THRIFT: return build(Encoder.THRIFT); default: throw new UnsupportedOperationException(sender.encoding().name()); } }
public final URLConnectionSender build() { if (encoding() == Encoding.JSON) { return mediaType("application/json").encoder(BytesMessageEncoder.JSON).autoBuild(); } else if (encoding() == Encoding.THRIFT) { return mediaType("application/x-thrift").encoder(BytesMessageEncoder.THRIFT).autoBuild(); } throw new UnsupportedOperationException("Unsupported encoding: " + encoding().name()); }
public final OkHttpSender build() { // bound the executor so that we get consistent performance ThreadPoolExecutor dispatchExecutor = new ThreadPoolExecutor(0, maxRequests(), 60, TimeUnit.SECONDS, // Using a synchronous queue means messages will send immediately until we hit max // in-flight requests. Once max requests are hit, send will block the caller, which is // the AsyncReporter flush thread. This is ok, as the AsyncReporter has a buffer of // unsent spans for this purpose. new SynchronousQueue<>(), Util.threadFactory("OkHttpSender Dispatcher", false)); Dispatcher dispatcher = new Dispatcher(dispatchExecutor); dispatcher.setMaxRequests(maxRequests()); dispatcher.setMaxRequestsPerHost(maxRequests()); clientBuilder().dispatcher(dispatcher).build(); if (encoding() == Encoding.JSON) { return encoder(RequestBodyMessageEncoder.JSON).autoBuild(); } else if (encoding() == Encoding.THRIFT) { return encoder(RequestBodyMessageEncoder.THRIFT).autoBuild(); } throw new UnsupportedOperationException("Unsupported encoding: " + encoding().name()); }