Java Code Examples for zipkin2.codec.SpanBytesDecoder#THRIFT

The following examples show how to use zipkin2.codec.SpanBytesDecoder#THRIFT . 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: ZipkinHttpCollector.java    From pivotal-bank-demo with Apache License 2.0 6 votes vote down vote up
@Autowired
ZipkinHttpCollector(
    StorageComponent storage, CollectorSampler sampler, CollectorMetrics metrics) {
  this.metrics = metrics.forTransport("http");
  this.collector =
      Collector.newBuilder(getClass())
          .storage(storage)
          .sampler(sampler)
          .metrics(this.metrics)
          .build();
  this.JSON_V2 = new HttpCollector(SpanBytesDecoder.JSON_V2);
  this.PROTO3 = new HttpCollector(SpanBytesDecoder.PROTO3);
  this.JSON_V1 = new HttpCollector(SpanBytesDecoder.JSON_V1);
  this.THRIFT = new HttpCollector(SpanBytesDecoder.THRIFT);
  this.errorCallback =
      new Receiver.ErrorCallback() {
        @Override
        public void error(HttpServerExchange exchange, IOException e) {
          ZipkinHttpCollector.this.metrics.incrementMessagesDropped();
          ZipkinHttpCollector.error(exchange, e);
        }
      };
}
 
Example 2
Source File: SpanV1JettyHandler.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) {
    response.setContentType("application/json");
    response.setCharacterEncoding("utf-8");

    try {
        String type = request.getHeader("Content-Type");

        int encode = type != null && type.contains("/x-thrift") ? SpanEncode.THRIFT : SpanEncode.JSON_V1;

        SpanBytesDecoder decoder = SpanEncode.isThrift(encode) ? SpanBytesDecoder.THRIFT : SpanBytesDecoder.JSON_V1;

        SpanProcessor processor = new SpanProcessor(sourceReceiver);
        processor.convert(config, decoder, request);

        response.setStatus(202);
    } catch (Exception e) {
        response.setStatus(500);

        logger.error(e.getMessage(), e);
    }
}
 
Example 3
Source File: HttpReporterTest.java    From servicetalk with Apache License 2.0 5 votes vote down vote up
private List<Span> verifyRequest(final HttpRequest request, final boolean multipleSpans) {
    SpanBytesDecoder decoder;
    switch (codec) {
        case JSON_V1:
            assertThat("Unexpected path.", request.path(), equalTo(V1_PATH));
            decoder = SpanBytesDecoder.JSON_V1;
            break;
        case JSON_V2:
            assertThat("Unexpected path.", request.path(), equalTo(V2_PATH));
            decoder = SpanBytesDecoder.JSON_V2;
            break;
        case THRIFT:
            assertThat("Unexpected path.", request.path(), equalTo(V2_PATH));
            decoder = SpanBytesDecoder.THRIFT;
            break;
        case PROTO3:
            assertThat("Unexpected path.", request.path(), equalTo(V2_PATH));
            decoder = SpanBytesDecoder.PROTO3;
            break;
        default:
            throw new IllegalArgumentException("Unknown codec: " + codec);
    }
    Buffer buffer = request.payloadBody();
    byte[] data = new byte[buffer.readableBytes()];
    buffer.readBytes(data);
    List<Span> decoded = new ArrayList<>();
    if (multipleSpans) {
        decoder.decodeList(data, decoded);
    } else {
        decoder.decode(data, decoded);
    }
    return decoded;
}
 
Example 4
Source File: FakeSender.java    From zipkin-finagle with Apache License 2.0 5 votes vote down vote up
static FakeSender create() {
  return new FakeSender(
      Encoding.THRIFT,
      Integer.MAX_VALUE,
      BytesMessageEncoder.forEncoding(Encoding.THRIFT),
      SpanBytesEncoder.THRIFT,
      SpanBytesDecoder.THRIFT,
      spans -> {
      }
  );
}