Java Code Examples for zipkin2.codec.Encoding#JSON

The following examples show how to use zipkin2.codec.Encoding#JSON . 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: AbstractSender.java    From zipkin-aws with Apache License 2.0 5 votes vote down vote up
@Override public Call<Void> sendSpans(List<byte[]> list) {
  if (closeCalled) throw new IllegalStateException("closed");

  byte[] encodedSpans = BytesMessageEncoder.forEncoding(encoding()).encode(list);
  String body =
      encoding() == Encoding.JSON && isAscii(encodedSpans)
          ? new String(encodedSpans, StandardCharsets.UTF_8)
          : Base64.getEncoder().encodeToString(encodedSpans);

  return call(SendMessageRequest.builder().messageBody(body).queueUrl(queueUrl).build());
}
 
Example 3
Source File: FakeSender.java    From zipkin-reporter-java with Apache License 2.0 5 votes vote down vote up
public static FakeSender create() {
  return new FakeSender(
      Encoding.JSON,
      Integer.MAX_VALUE,
      BytesMessageEncoder.forEncoding(Encoding.JSON),
      SpanBytesEncoder.JSON_V2,
      SpanBytesDecoder.JSON_V2,
      spans -> {
      }
  );
}
 
Example 4
Source File: TarsTraceZipkinConfiguration.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Encoding createCodec() throws NotSupportedSuchSampleEncodingException {
	if ("json".endsWith(serverConfig.getSampleEncoding())) {
		return Encoding.JSON;
	}
	if ("proto".endsWith(serverConfig.getSampleEncoding())) {
		return Encoding.PROTO3;
	}
	throw new NotSupportedSuchSampleEncodingException("unsupported sample encoding");
}
 
Example 5
Source File: ITRabbitMQSender.java    From zipkin-reporter-java with Apache License 2.0 4 votes vote down vote up
/** Blocks until the callback completes to allow read-your-writes consistency during tests. */
static Call<Void> send(Sender sender, Span... spans) {
  SpanBytesEncoder bytesEncoder = sender.encoding() == Encoding.JSON
      ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3;
  return sender.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList()));
}
 
Example 6
Source File: RestTemplateSenderTest.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
Call<Void> send(Span... spans) {
	SpanBytesEncoder bytesEncoder = this.sender.encoding() == Encoding.JSON
			? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3;
	return this.sender
			.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList()));
}
 
Example 7
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@Override
public Encoding encoding() {
	return Encoding.JSON;
}
 
Example 8
Source File: ZipkinAutoConfigurationTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
@Override
public Encoding encoding() {
	return Encoding.JSON;
}
 
Example 9
Source File: FakeSender.java    From zipkin-reporter-java with Apache License 2.0 4 votes vote down vote up
@Override public Encoding encoding() {
  return Encoding.JSON;
}
 
Example 10
Source File: InternalReporterTest.java    From zipkin-reporter-java with Apache License 2.0 4 votes vote down vote up
@Override public Encoding encoding() {
  return Encoding.JSON;
}
 
Example 11
Source File: RequestBodyMessageEncoder.java    From zipkin-reporter-java with Apache License 2.0 4 votes vote down vote up
JsonRequestBody(List<byte[]> values) {
  super(Encoding.JSON, CONTENT_TYPE, values);
}
 
Example 12
Source File: JsonV2Encoder.java    From zipkin-reporter-java with Apache License 2.0 4 votes vote down vote up
@Override public Encoding encoding() {
  return Encoding.JSON;
}
 
Example 13
Source File: SQSSenderTest.java    From zipkin-aws with Apache License 2.0 4 votes vote down vote up
Call<Void> send(Span... spans) {
  SpanBytesEncoder bytesEncoder =
      sender.encoding() == Encoding.JSON ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3;
  return sender.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList()));
}
 
Example 14
Source File: MutableSpanAsyncReporterTest.java    From brave with Apache License 2.0 4 votes vote down vote up
@Override public Encoding encoding() {
  return Encoding.JSON;
}
 
Example 15
Source File: SQSSenderTest.java    From zipkin-aws with Apache License 2.0 4 votes vote down vote up
Call<Void> send(Span... spans) {
  SpanBytesEncoder bytesEncoder =
      sender.encoding() == Encoding.JSON ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3;
  return sender.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList()));
}
 
Example 16
Source File: SQSAsyncSenderTest.java    From zipkin-aws with Apache License 2.0 4 votes vote down vote up
Call<Void> send(Span... spans) {
  SpanBytesEncoder bytesEncoder =
      sender.encoding() == Encoding.JSON ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3;
  return sender.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList()));
}
 
Example 17
Source File: KinesisSenderTest.java    From zipkin-aws with Apache License 2.0 4 votes vote down vote up
Call<Void> send(zipkin2.Span... spans) {
  SpanBytesEncoder bytesEncoder =
      sender.encoding() == Encoding.JSON ? SpanBytesEncoder.JSON_V2 : SpanBytesEncoder.PROTO3;
  return sender.sendSpans(Stream.of(spans).map(bytesEncoder::encode).collect(toList()));
}
 
Example 18
Source File: HttpSender.java    From zipkin-finagle with Apache License 2.0 4 votes vote down vote up
@Override public Encoding encoding() {
  return Encoding.JSON;
}
 
Example 19
Source File: StackdriverTraceAutoConfigurationTests.java    From spring-cloud-gcp with Apache License 2.0 4 votes vote down vote up
@Override
public Encoding encoding() {
	return Encoding.JSON;
}
 
Example 20
Source File: ZipkinRestTemplateSender.java    From sofa-tracer with Apache License 2.0 4 votes vote down vote up
@Override
public Encoding encoding() {
    return Encoding.JSON;
}