Ejemplo n.º 1
0
 /**
  * Create a new instance.
  *
  * @param zipkinCollectorHost Host for zipkin collector.
  * @param zipkinCollectorPort Port for zipkin collector.
  * @param params Zipkin Span Collector parameters.
  */
 public ZipkinSpanCollector(
     final String zipkinCollectorHost,
     final int zipkinCollectorPort,
     final ZipkinSpanCollectorParams params) {
   Validate.notEmpty(zipkinCollectorHost);
   Validate.notNull(params);
   clientProvider =
       new ZipkinCollectorClientProvider(
           zipkinCollectorHost, zipkinCollectorPort, params.getSocketTimeout());
   try {
     clientProvider.setup();
   } catch (final TException e) {
     if (params.failOnSetup()) {
       throw new IllegalStateException(e);
     } else {
       LOGGER.warn("Connection could not be established during setup.", e);
     }
   }
   spanQueue = new ArrayBlockingQueue<Span>(params.getQueueSize());
   executorService = Executors.newFixedThreadPool(params.getNrOfThreads());
   for (int i = 1; i <= params.getNrOfThreads(); i++) {
     final SpanProcessingThread spanProcessingThread =
         new SpanProcessingThread(spanQueue, clientProvider, params.getBatchSize());
     spanProcessingThreads.add(spanProcessingThread);
     futures.add(executorService.submit(spanProcessingThread));
   }
 }
Ejemplo n.º 2
0
 private ZipkinCollectorClientProvider createZipkinCollectorClientProvider(
     String zipkinCollectorHost, int zipkinCollectorPort, ZipkinSpanCollectorParams params) {
   ZipkinCollectorClientProvider clientProvider =
       new ZipkinCollectorClientProvider(
           zipkinCollectorHost, zipkinCollectorPort, params.getSocketTimeout());
   try {
     clientProvider.setup();
   } catch (final TException e) {
     if (params.failOnSetup()) {
       throw new IllegalStateException(e);
     } else {
       LOGGER.log(Level.WARNING, "Connection could not be established during setup.", e);
     }
   }
   return clientProvider;
 }