@Override public void incrementMessages() { delegate.incrementMessages(); }
@Override public ListenableFuture<ResultCode> log(List<LogEntry> messages) { metrics.incrementMessages(); List<Span> spans; try {
LOG.debug("Kafka polling returned batch of {} messages.", consumerRecords.count()); for (ConsumerRecord<byte[], byte[]> record : consumerRecords) { metrics.incrementMessages(); final byte[] bytes = record.value();
@Override public void handleDelivery( String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) { metrics.incrementMessages(); this.collector.acceptSpans(body, NOOP); } }
@Override public void run() { ConsumerIterator<byte[], byte[]> messages = stream.iterator(); while (messages.hasNext()) { byte[] bytes = messages.next().message(); metrics.incrementMessages(); if (bytes.length < 2) { // need two bytes to check if protobuf metrics.incrementMessagesDropped(); continue; } // If we received legacy single-span encoding, decode it into a singleton list if (!protobuf3(bytes) && bytes[0] <= 16 && bytes[0] != 12 /* thrift, but not a list */) { try { metrics.incrementBytes(bytes.length); Span span = SpanBytesDecoder.THRIFT.decodeOne(bytes); collector.accept(Collections.singletonList(span), NOOP); } catch (RuntimeException e) { metrics.incrementMessagesDropped(); } } else { collector.acceptSpans(bytes, NOOP); } } }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { boolean v2 = exchange.getRelativePath().equals("/api/v2/spans"); boolean v1 = !v2 && exchange.getRelativePath().equals("/api/v1/spans"); if (!v2 && !v1) { next.handleRequest(exchange); return; } if (!POST.equals(exchange.getRequestMethod())) { next.handleRequest(exchange); return; } String contentTypeValue = exchange.getRequestHeaders().getFirst(CONTENT_TYPE); boolean json = contentTypeValue == null || contentTypeValue.startsWith("application/json"); boolean thrift = !json && contentTypeValue.startsWith("application/x-thrift"); boolean proto = v2 && !json && contentTypeValue.startsWith("application/x-protobuf"); if (!json && !thrift && !proto) { exchange .setStatusCode(400) .getResponseSender() .send("unsupported content type " + contentTypeValue + "\n"); return; } HttpCollector collector = v2 ? (json ? JSON_V2 : PROTO3) : thrift ? THRIFT : JSON_V1; metrics.incrementMessages(); exchange.getRequestReceiver().receiveFullBytes(collector, errorCallback); }
MockResponse acceptSpans(RecordedRequest request, SpanBytesDecoder decoder) { metrics.incrementMessages(); byte[] body = request.getBody().readByteArray(); String encoding = request.getHeader("Content-Encoding");