io.jaegertracing.Configuration.SenderConfiguration Java Examples

The following examples show how to use io.jaegertracing.Configuration.SenderConfiguration. 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: OpenTracingUtil.java    From problematic-microservices with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private static void configureOpenTracing(Properties configuration, String serviceName) {
	Tracer tracer = null;
	String tracerName = configuration.getProperty("tracer");
	if ("jaeger".equals(tracerName)) {
		SamplerConfiguration samplerConfig = new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1);
		SenderConfiguration senderConfig = new SenderConfiguration()
				.withAgentHost(configuration.getProperty("jaeger.reporter.host"))
				.withAgentPort(Integer.decode(configuration.getProperty("jaeger.reporter.port")));
		ReporterConfiguration reporterConfig = new ReporterConfiguration().withLogSpans(true)
				.withFlushInterval(1000).withMaxQueueSize(10000).withSender(senderConfig);
		tracer = new Configuration(serviceName).withSampler(samplerConfig).withReporter(reporterConfig).getTracer();
	} else if ("zipkin".equals(tracerName)) {
		OkHttpSender sender = OkHttpSender.create("http://" + configuration.getProperty("zipkin.reporter.host")
				+ ":" + configuration.getProperty("zipkin.reporter.port") + "/api/v2/spans");
		Reporter<Span> reporter = AsyncReporter.builder(sender).build();
		tracer = BraveTracer
				.create(Tracing.newBuilder().localServiceName(serviceName).spanReporter(reporter).build());
	}
	GlobalTracer.register(new DelegatingJfrTracer(tracer));
}
 
Example #2
Source File: Client.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Tracer tracer = new Configuration("cxf-client")
        .withSampler(new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1))
        .withReporter(new ReporterConfiguration().withSender(
            new SenderConfiguration()
                .withEndpoint("http://localhost:14268/api/traces")
        ))
        .getTracer();
    
    final OpenTracingClientProvider provider = new OpenTracingClientProvider(tracer);
    final javax.ws.rs.client.Client client = ClientBuilder.newClient().register(provider);
    
    final Response response = client
        .target("http://localhost:8084/catalog")
        .request()
        .accept(MediaType.APPLICATION_JSON)
        .get();
  
    LOG.info("Response: {}", response.readEntity(String.class));
    response.close();
      
    // Allow Tracer to flush
    Thread.sleep(1000);
}
 
Example #3
Source File: Server.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Bean
Tracer tracer() {
    return new Configuration("camel-server")
        .withSampler(
            new SamplerConfiguration()
                .withType(ConstSampler.TYPE)
                .withParam(1))
        .withReporter(new ReporterConfiguration().withSender(
            new SenderConfiguration()
                .withEndpoint("http://localhost:14268/api/traces")
        ))
        .withCodec(
            new CodecConfiguration()
                .withCodec(Builtin.TEXT_MAP, new TextMapCodec(true))
        )
        .getTracer();
}
 
Example #4
Source File: Client.java    From cxf with Apache License 2.0 6 votes vote down vote up
public static void main(final String[] args) throws Exception {
    final Tracer tracer = new Configuration("tracer-client") 
        .withSampler(new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1))
        .withReporter(new ReporterConfiguration().withSender(
            new SenderConfiguration() {
                @Override
                public Sender getSender() {
                    return new Slf4jLogSender();
                }
            }
        ))
        .getTracer();
    final OpenTracingClientProvider provider = new OpenTracingClientProvider(tracer);

    final Response response = WebClient
        .create("http://localhost:9000/catalog", Arrays.asList(provider))
        .accept(MediaType.APPLICATION_JSON)
        .get();

    System.out.println(response.readEntity(String.class));
    response.close();
}
 
Example #5
Source File: AllInOne.java    From batfish with Apache License 2.0 5 votes vote down vote up
private void initTracer() {
  Configuration config =
      new Configuration(_settings.getServiceName())
          .withSampler(new SamplerConfiguration().withType("const").withParam(1))
          .withReporter(
              new ReporterConfiguration()
                  .withSender(
                      SenderConfiguration.fromEnv()
                          .withAgentHost(_settings.getTracingAgentHost())
                          .withAgentPort(_settings.getTracingAgentPort()))
                  .withLogSpans(false));
  GlobalTracer.registerIfAbsent(config.getTracer());
}
 
Example #6
Source File: Client.java    From batfish with Apache License 2.0 5 votes vote down vote up
private void initTracer() {
  Configuration config =
      new Configuration(_settings.getServiceName())
          .withSampler(new SamplerConfiguration().withType("const").withParam(1))
          .withReporter(
              new ReporterConfiguration()
                  .withSender(
                      SenderConfiguration.fromEnv()
                          .withAgentHost(_settings.getTracingAgentHost())
                          .withAgentPort(_settings.getTracingAgentPort()))
                  .withLogSpans(false));
  GlobalTracer.registerIfAbsent(config.getTracer());
}
 
Example #7
Source File: Main.java    From batfish with Apache License 2.0 5 votes vote down vote up
private static void initTracer() {
  Configuration config =
      new Configuration(_settings.getServiceName())
          .withSampler(new SamplerConfiguration().withType("const").withParam(1))
          .withReporter(
              new ReporterConfiguration()
                  .withSender(
                      SenderConfiguration.fromEnv()
                          .withAgentHost(_settings.getTracingAgentHost())
                          .withAgentPort(_settings.getTracingAgentPort()))
                  .withLogSpans(false));
  GlobalTracer.registerIfAbsent(config.getTracer());
}
 
Example #8
Source File: Driver.java    From batfish with Apache License 2.0 5 votes vote down vote up
private static void initTracer() {
  io.jaegertracing.Configuration config =
      new io.jaegertracing.Configuration(_mainSettings.getServiceName())
          .withSampler(new SamplerConfiguration().withType("const").withParam(1))
          .withReporter(
              new ReporterConfiguration()
                  .withSender(
                      SenderConfiguration.fromEnv()
                          .withAgentHost(_mainSettings.getTracingAgentHost())
                          .withAgentPort(_mainSettings.getTracingAgentPort()))
                  .withLogSpans(false));
  GlobalTracer.registerIfAbsent(config.getTracer());
}
 
Example #9
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Bean @Qualifier("cxf")
Tracer cxfTracer() {
    return new Configuration("cxf-service")
            .withSampler(new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1))
            .withReporter(new ReporterConfiguration().withSender(
                new SenderConfiguration()
                    .withEndpoint("http://localhost:14268/api/traces")
            ))
            .getTracer();
}
 
Example #10
Source File: Server.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected Server() throws Exception {
    org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server(9000);

    // Register and map the dispatcher servlet
    final ServletHolder servletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
    final ServletContextHandler context = new ServletContextHandler();
    context.setContextPath("/");
    context.addServlet(servletHolder, "/*");

    servletHolder.setInitParameter("javax.ws.rs.Application",
        CatalogApplication.class.getName());

    final Tracer tracer = new Configuration("tracer-server")
        .withSampler(new SamplerConfiguration().withType(ConstSampler.TYPE).withParam(1))
        .withReporter(new ReporterConfiguration().withSender(
            new SenderConfiguration() {
                @Override
                public Sender getSender() {
                    return new Slf4jLogSender();
                }
            }
        ))
        .getTracer();
    GlobalTracer.registerIfAbsent(tracer);
    
    server.setHandler(context);
    server.start();
    server.join();
}