zipkin2.codec.BytesEncoder Java Examples

The following examples show how to use zipkin2.codec.BytesEncoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestTemplateSender.java    From spring-cloud-sleuth with Apache License 2.0 6 votes vote down vote up
RestTemplateSender(RestTemplate restTemplate, String baseUrl,
		BytesEncoder<Span> encoder) {
	this.restTemplate = restTemplate;
	this.encoding = encoder.encoding();
	if (encoder.equals(JSON_V2)) {
		this.mediaType = MediaType.APPLICATION_JSON;
		this.url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + "api/v2/spans";
	}
	else if (this.encoding == Encoding.PROTO3) {
		this.mediaType = MediaType.parseMediaType("application/x-protobuf");
		this.url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + "api/v2/spans";
	}
	else if (this.encoding == Encoding.JSON) {
		this.mediaType = MediaType.APPLICATION_JSON;
		this.url = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + "api/v1/spans";
	}
	else {
		throw new UnsupportedOperationException(
				"Unsupported encoding: " + this.encoding.name());
	}
	this.messageEncoder = BytesMessageEncoder.forEncoding(this.encoding);
}
 
Example #2
Source File: FakeSender.java    From zipkin-finagle with Apache License 2.0 5 votes vote down vote up
FakeSender(
    Encoding encoding,
    int messageMaxBytes,
    BytesMessageEncoder messageEncoder,
    BytesEncoder<Span> encoder,
    BytesDecoder<Span> decoder,
    Consumer<List<Span>> onSpans
) {
  this.encoding = encoding;
  this.messageMaxBytes = messageMaxBytes;
  this.messageEncoder = messageEncoder;
  this.encoder = encoder;
  this.decoder = decoder;
  this.onSpans = onSpans;
}
 
Example #3
Source File: AsyncReporter.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
/** Builds an async reporter that encodes arbitrary spans as they are reported. */
public <S> AsyncReporter<S> build(BytesEncoder<S> encoder) {
  if (encoder == null) throw new NullPointerException("encoder == null");

  if (encoder.encoding() != sender.encoding()) {
    throw new IllegalArgumentException(String.format(
        "Encoder doesn't match Sender: %s %s", encoder.encoding(), sender.encoding()));
  }

  return new BoundedAsyncReporter<>(this, encoder);
}
 
Example #4
Source File: AsyncReporter.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
BoundedAsyncReporter(Builder builder, BytesEncoder<S> encoder) {
  this.pending = new ByteBoundedQueue<>(builder.queuedMaxSpans, builder.queuedMaxBytes);
  this.sender = builder.sender;
  this.messageMaxBytes = builder.messageMaxBytes;
  this.messageTimeoutNanos = builder.messageTimeoutNanos;
  this.closeTimeoutNanos = builder.closeTimeoutNanos;
  this.closed = new AtomicBoolean(false);
  // pretend we already started when config implies no thread that flushes the queue in a loop.
  this.started = new AtomicBoolean(builder.messageTimeoutNanos == 0);
  this.close = new CountDownLatch(builder.messageTimeoutNanos > 0 ? 1 : 0);
  this.metrics = builder.metrics;
  this.threadFactory = builder.threadFactory;
  this.encoder = encoder;
}
 
Example #5
Source File: FakeSender.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
FakeSender(
    Encoding encoding,
    int messageMaxBytes,
    BytesMessageEncoder messageEncoder,
    BytesEncoder<Span> encoder,
    BytesDecoder<Span> decoder,
    Consumer<List<Span>> onSpans
) {
  this.encoding = encoding;
  this.messageMaxBytes = messageMaxBytes;
  this.messageEncoder = messageEncoder;
  this.encoder = encoder;
  this.decoder = decoder;
  this.onSpans = onSpans;
}
 
Example #6
Source File: ZipkinSpanExporter.java    From opentelemetry-java with Apache License 2.0 4 votes vote down vote up
ZipkinSpanExporter(BytesEncoder<Span> encoder, Sender sender, String serviceName) {
  this.encoder = encoder;
  this.sender = sender;
  this.localEndpoint = produceLocalEndpoint(serviceName);
}
 
Example #7
Source File: ZipkinSpanExporter.java    From opentelemetry-java with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the {@link BytesEncoder}, which controls the format used by the {@link Sender}. Defaults
 * to the {@link SpanBytesEncoder#JSON_V2}.
 *
 * @param encoder the {@code BytesEncoder} to use.
 * @return this.
 * @see SpanBytesEncoder
 * @since 0.4.0
 */
public Builder setEncoder(BytesEncoder<Span> encoder) {
  this.encoder = encoder;
  return this;
}