Java Code Examples for zipkin2.codec.SpanBytesDecoder#JSON_V2
The following examples show how to use
zipkin2.codec.SpanBytesDecoder#JSON_V2 .
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 |
@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: SpanV2JettyHandler.java From skywalking with Apache License 2.0 | 6 votes |
@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-protobuf") ? SpanEncode.PROTO3 : SpanEncode.JSON_V2; SpanBytesDecoder decoder = SpanEncode.isProto3(encode) ? SpanBytesDecoder.PROTO3 : SpanBytesDecoder.JSON_V2; 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 |
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: UdpReporterTest.java From servicetalk with Apache License 2.0 | 5 votes |
@Test public void reportAfterClose() throws Exception { try (TestReceiver receiver = new TestReceiver(SpanBytesDecoder.JSON_V2)) { UdpReporter reporter = buildReporter((InetSocketAddress) receiver.channel.localAddress(), Codec.JSON_V2); assertThat("Unexpected check state.", reporter.check(), is(OK)); reporter.close(); assertThat("Unexpected check state.", reporter.check(), is(not(OK))); assertThrows("Report post close accepted.", RuntimeException.class, () -> reporter.report(newSpan("1"))); } }
Example 5
Source File: FakeSender.java From zipkin-reporter-java with Apache License 2.0 | 5 votes |
public static FakeSender create() { return new FakeSender( Encoding.JSON, Integer.MAX_VALUE, BytesMessageEncoder.forEncoding(Encoding.JSON), SpanBytesEncoder.JSON_V2, SpanBytesDecoder.JSON_V2, spans -> { } ); }