KinesisCollector(Builder builder) { this.collector = builder.delegate.build(); this.appName = builder.appName; this.streamName = builder.streamName; this.credentialsProvider = builder.credentialsProvider; this.regionName = builder.regionName; executor = Executors.newSingleThreadExecutor( new ThreadFactoryBuilder() .setNameFormat("KinesisCollector-" + streamName + "-%d") .build()); }
KafkaCollectorWorker(KafkaCollector.Builder builder) { properties = builder.properties; topics = Arrays.asList(builder.topic.split(",")); collector = builder.delegate.build(); metrics = builder.metrics; }
@Override public IEventProcessor createEventProcessor(PartitionContext context) throws Exception { hosts.putIfAbsent( context.getPartitionId(), new ZipkinEventProcessor(builder.delegate.build(), builder.checkpointBatchSize)); return hosts.get(context.getPartitionId()); } };
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; }
@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; }
ScribeSpanConsumer(ScribeCollector.Builder builder) { this.collector = builder.delegate.build(); this.metrics = builder.metrics; this.category = builder.category; }
ZipkinDispatcher(StorageComponent storage, CollectorMetrics metrics, MockWebServer server) { this.consumer = Collector.newBuilder(getClass()).storage(storage).metrics(metrics).build(); this.metrics = metrics; this.server = server; }