Connection compute() { Connection connection; try { connection = (builder.addresses == null) ? builder.connectionFactory.newConnection() : builder.connectionFactory.newConnection(builder.addresses); declareQueueIfMissing(connection); } catch (IOException | TimeoutException e) { throw new IllegalStateException("Unable to establish connection to RabbitMQ server", e); } Collector collector = builder.delegate.build(); CollectorMetrics metrics = builder.metrics; for (int i = 0; i < builder.concurrency; i++) { String name = RabbitMQSpanConsumer.class.getName() + i; try { // this sets up a channel for each consumer thread. // We don't track channels, as the connection will close its channels implicitly Channel channel = connection.createChannel(); RabbitMQSpanConsumer consumer = new RabbitMQSpanConsumer(channel, collector, metrics); channel.basicConsume(builder.queue, true, name, consumer); } catch (IOException e) { throw new IllegalStateException("Failed to start RabbitMQ consumer " + name, e); } } return connection; }
@Override public Builder metrics(CollectorMetrics metrics) { if (metrics == null) throw new NullPointerException("metrics == null"); this.metrics = metrics.forTransport("rabbitmq"); this.delegate.metrics(this.metrics); return this; }
@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); } }; }
LazyStreams(Builder builder, LazyConnector connector) { this.streams = builder.streams; this.topic = builder.topic; this.collector = builder.delegate.build(); this.metrics = builder.metrics; this.connector = connector; }
KafkaCollectorWorker(KafkaCollector.Builder builder) { properties = builder.properties; topics = Arrays.asList(builder.topic.split(",")); collector = builder.delegate.build(); metrics = builder.metrics; }
@Override public Builder sampler(CollectorSampler sampler) { this.delegate.sampler(sampler); return this; }
@Override public Builder metrics(CollectorMetrics metrics) { if (metrics == null) throw new NullPointerException("metrics == null"); this.metrics = metrics.forTransport("kafka"); delegate.metrics(this.metrics); return this; }
@Override public Builder sampler(CollectorSampler sampler) { delegate.sampler(sampler); return this; }
@Override public Builder sampler(CollectorSampler sampler) { delegate.sampler(sampler); return this; }
@Override public Builder metrics(CollectorMetrics metrics) { if (metrics == null) throw new NullPointerException("metrics == null"); delegate.metrics(metrics.forTransport("kinesis")); return this; }
ScribeSpanConsumer(ScribeCollector.Builder builder) { this.collector = builder.delegate.build(); this.metrics = builder.metrics; this.category = builder.category; }
@Override public Builder storage(StorageComponent storage) { delegate.storage(storage); return this; }
@Override public Builder storage(StorageComponent storage) { this.delegate.storage(storage); return this; }
@Override public Builder storage(StorageComponent storage) { delegate.storage(storage); return this; }
@Override public Builder storage(StorageComponent storage) { delegate.storage(storage); return this; }
@Override public IEventProcessor createEventProcessor(PartitionContext context) throws Exception { hosts.putIfAbsent( context.getPartitionId(), new ZipkinEventProcessor(builder.delegate.build(), builder.checkpointBatchSize)); return hosts.get(context.getPartitionId()); } };
@Override public Builder metrics(CollectorMetrics metrics) { delegate.metrics(metrics); return this; }
@Override public Builder sampler(CollectorSampler sampler) { delegate.sampler(sampler); return this; }
@Override public Builder sampler(CollectorSampler collectorSampler) { delegate.sampler(collectorSampler); return this; }