Example #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));
   }
 }
Example #2
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) {
    checkNotBlank(zipkinCollectorHost, "Null or empty zipkinCollectorHost");
    checkNotNull(params, "Null params");

    spanQueue = new ArrayBlockingQueue<Span>(params.getQueueSize());
    executorService = Executors.newFixedThreadPool(params.getNrOfThreads());

    for (int i = 1; i <= params.getNrOfThreads(); i++) {

      // Creating a client provider for every spanProcessingThread.
      ZipkinCollectorClientProvider clientProvider =
          createZipkinCollectorClientProvider(zipkinCollectorHost, zipkinCollectorPort, params);
      final SpanProcessingThread spanProcessingThread =
          new SpanProcessingThread(spanQueue, clientProvider, params.getBatchSize());
      spanProcessingThreads.add(spanProcessingThread);
      clientProviders.add(clientProvider);
      futures.add(executorService.submit(spanProcessingThread));
    }
  }