zipkin.reporter.AsyncReporter Java Examples

The following examples show how to use zipkin.reporter.AsyncReporter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracersGenerator.java    From spark-dependencies with Apache License 2.0 6 votes vote down vote up
public static Tuple<Tracing, Flushable> createZipkin(String serviceName, String collectorUrl) {
  Sender sender = OkHttpSender.builder()
    .endpoint(collectorUrl + "/api/v1/spans")
    .encoding(Encoding.JSON)
    .build();

  AsyncReporter<Span> reporter = AsyncReporter.builder(sender)
      .closeTimeout(1, TimeUnit.MILLISECONDS)
      .build();
  return new Tuple<>(Tracing.newBuilder()
      .localServiceName(serviceName)
      .sampler(Sampler.ALWAYS_SAMPLE)
      .traceId128Bit(true)
      .reporter(reporter)
      .build(), () -> reporter.flush());
}
 
Example #2
Source File: ZipkinFraction.java    From thorntail with Apache License 2.0 5 votes vote down vote up
public Brave getBraveInstance() {

        Brave.Builder builder = new Brave.Builder(name.get());

        if (this.url.isDefault()) {
            builder.reporter(new LoggingReporter())
                           .traceSampler(Sampler.create(1.0f));
        } else {
            AsyncReporter<Span> asyncReporter = AsyncReporter.builder(URLConnectionSender.create(url.get())).build();
            builder.reporter(asyncReporter)
                    .traceSampler(Sampler.create(rate.get()));
        }
        return builder.build();
    }
 
Example #3
Source File: Constant.java    From grpc-by-example-java with Apache License 2.0 5 votes vote down vote up
public static Brave brave(String serviceName) {
  return new Brave.Builder(serviceName)
      .traceSampler(Sampler.ALWAYS_SAMPLE)
      .reporter(AsyncReporter.builder(URLConnectionSender.builder()
          .endpoint("http://docker-machine.dev:8080/api/v1/spans")
          .build()).build())
      .build();
}
 
Example #4
Source File: BraveProducer.java    From hawkular-apm with Apache License 2.0 5 votes vote down vote up
@Produces
@Singleton
public Brave getBrave() {
    String port = System.getenv("TRACING_PORT");
    if (port == null) {
        throw new IllegalStateException("Environmental variable TRACING_PORT is not set!");
    }

    return new Brave.Builder("wildfly-swarm")
            .reporter(AsyncReporter.builder(OkHttpSender.builder()
                    .endpoint("http://tracing-server:" + port + "/api/v1/spans")
                    .build())
                .build())
            .build();
}
 
Example #5
Source File: BaseETest.java    From jaeger-kubernetes with Apache License 2.0 4 votes vote down vote up
protected Tracing createZipkinTracer(String serviceName) {
  return Tracing.newBuilder()
          .localServiceName(serviceName)
          .reporter(AsyncReporter.builder(OkHttpSender.create(zipkinUrl + "api/v1/spans"))
                  .build()).build();
}
 
Example #6
Source File: TracingEndpointCaller.java    From odata with Apache License 2.0 4 votes vote down vote up
public TracingEndpointCaller(Properties properties) {
    Integer timeout = getIntegerProperty(properties, CLIENT_CONNECTION_TIMEOUT, CLIENT_TIMEOUT_DEFAULT);

    String proxyServerHostName = getStringProperty(properties, CLIENT_SERVICE_PROXY_HOST_NAME);
    Integer proxyPort = getIntegerProperty(properties, CLIENT_SERVICE_PROXY_PORT);
    Integer proxyServerPort = proxyPort == null ? CLIENT_PROXY_PORT_DEFAULT : proxyPort;

    RequestConfig config = RequestConfig.custom()
            .setConnectTimeout(timeout)
            .setConnectionRequestTimeout(timeout)
            .setSocketTimeout(timeout)
            .build();

    HttpClientBuilder httpClientBuilder = HttpClients.custom()
            .setConnectionManager(new PoolingHttpClientConnectionManager())
            .setDefaultRequestConfig(config);
    if (!isBlank(proxyServerHostName) && proxyServerPort > 0) {
        httpClientBuilder.setProxy(new HttpHost(proxyServerHostName, proxyServerPort));
    }

    // load application.properties to know zipkin host, service name and how often to collect spans
    Properties applicationProperties = new Properties();
    try (InputStream stream = this.getClass().getResourceAsStream(APPLICATION_PROPERTIES_FILE_NAME)) {
        if (stream != null) {
            applicationProperties.load(stream);
        }
    } catch (IOException e) {
        LOG.warn("'{}' file is not available in the classpath", APPLICATION_PROPERTIES_FILE_NAME);
    }

    Brave brave = new Brave.Builder(applicationProperties.getProperty("spring.application.name", "cil-call"))
            .traceSampler(Sampler.create(
                    Float.valueOf(applicationProperties.getProperty("spring.sleuth.sampler.percentage", "1.0"))))
            .reporter(AsyncReporter.builder(URLConnectionSender.builder().endpoint(
                    applicationProperties.getProperty("spring.zipkin.baseUrl", DEFAULT_ZIPKIN_HOSTNAME)).build())
                    .build()).build();

    closeableHttpClient = httpClientBuilder
            .addInterceptorFirst(BraveHttpRequestInterceptor.builder(brave).build())
                    //new BraveHttpRequestInterceptor(brave.clientRequestInterceptor(),
                    //new DefaultSpanNameProvider()))
            .addInterceptorFirst(BraveHttpResponseInterceptor.builder(brave).build())
                    //new BraveHttpResponseInterceptor(brave.clientResponseInterceptor()))
            .build();
}