io.jaegertracing.spi.Reporter Java Examples

The following examples show how to use io.jaegertracing.spi.Reporter. 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: JaegerAutoConfiguration.java    From java-spring-jaeger with Apache License 2.0 6 votes vote down vote up
@Bean
public io.opentracing.Tracer tracer(Sampler sampler,
                                    Reporter reporter,
                                    Metrics metrics,
                                    JaegerConfigurationProperties properties) {

  final JaegerTracer.Builder builder =
      new JaegerTracer.Builder(properties.getServiceName())
          .withReporter(reporter)
          .withSampler(sampler)
          .withTags(properties.determineTags())
          .withMetrics(metrics);

  tracerCustomizers.forEach(c -> c.customize(builder));

  return builder.build();
}
 
Example #2
Source File: JaegerAutoConfiguration.java    From java-spring-jaeger with Apache License 2.0 6 votes vote down vote up
@ConditionalOnMissingBean
@Bean
public Reporter reporter(JaegerConfigurationProperties properties,
                         Metrics metrics,
                         @Autowired(required = false) ReporterAppender reporterAppender) {

  List<Reporter> reporters = new LinkedList<>();
  RemoteReporter remoteReporter = properties.getRemoteReporter();

  JaegerConfigurationProperties.HttpSender httpSender = properties.getHttpSender();
  if (!StringUtils.isEmpty(httpSender.getUrl())) {
    reporters.add(getHttpReporter(metrics, remoteReporter, httpSender));
  } else {
    reporters.add(getUdpReporter(metrics, remoteReporter, properties.getUdpSender()));
  }

  if (properties.isLogSpans()) {
    reporters.add(new LoggingReporter());
  }

  if (reporterAppender != null) {
    reporterAppender.append(reporters);
  }

  return new CompositeReporter(reporters.toArray(new Reporter[reporters.size()]));
}
 
Example #3
Source File: JaegerAutoConfiguration.java    From java-spring-jaeger with Apache License 2.0 6 votes vote down vote up
private Reporter getHttpReporter(Metrics metrics,
                                 RemoteReporter remoteReporter,
                                 JaegerConfigurationProperties.HttpSender httpSenderProperties) {
  io.jaegertracing.thrift.internal.senders.HttpSender.Builder builder =
      new io.jaegertracing.thrift.internal.senders.HttpSender.Builder(httpSenderProperties.getUrl());
  if (httpSenderProperties.getMaxPayload() != null) {
    builder = builder.withMaxPacketSize(httpSenderProperties.getMaxPayload());
  }
  if (!StringUtils.isEmpty(httpSenderProperties.getUsername())
      && !StringUtils.isEmpty(httpSenderProperties.getPassword())) {
    builder.withAuth(httpSenderProperties.getUsername(), httpSenderProperties.getPassword());
  } else if (!StringUtils.isEmpty(httpSenderProperties.getAuthToken())) {
    builder.withAuth(httpSenderProperties.getAuthToken());
  }

  return createReporter(metrics, remoteReporter, builder.build());
}
 
Example #4
Source File: JaegerAutoConfiguration.java    From java-spring-jaeger with Apache License 2.0 6 votes vote down vote up
private Reporter createReporter(Metrics metrics,
                                RemoteReporter remoteReporter, Sender udpSender) {
  io.jaegertracing.internal.reporters.RemoteReporter.Builder builder =
      new io.jaegertracing.internal.reporters.RemoteReporter.Builder()
          .withSender(udpSender)
          .withMetrics(metrics);

  if (remoteReporter.getFlushInterval() != null) {
    builder.withFlushInterval(remoteReporter.getFlushInterval());
  }
  if (remoteReporter.getMaxQueueSize() != null) {
    builder.withMaxQueueSize(remoteReporter.getMaxQueueSize());
  }

  return builder.build();
}
 
Example #5
Source File: JaegerAllInOne.java    From jaeger-analytics-java with Apache License 2.0 5 votes vote down vote up
public JaegerTracer createTracer(String serviceName) {
  String endpoint = String.format("http://localhost:%d/api/traces", getCollectorThriftPort());
  Sender sender = new HttpSender.Builder(endpoint)
      .build();
  Reporter reporter = new RemoteReporter.Builder()
      .withSender(sender)
      .build();
  Builder tracerBuilder = new Builder(serviceName)
      .withSampler(new ConstSampler(true))
      .withReporter(reporter);
  return tracerBuilder.build();
}
 
Example #6
Source File: JaegerAutoConfiguration.java    From java-spring-jaeger with Apache License 2.0 5 votes vote down vote up
private Reporter getUdpReporter(Metrics metrics,
                                RemoteReporter remoteReporter,
                                JaegerConfigurationProperties.UdpSender udpSenderProperties) {
  io.jaegertracing.thrift.internal.senders.UdpSender udpSender =
      new io.jaegertracing.thrift.internal.senders.UdpSender(
          udpSenderProperties.getHost(), udpSenderProperties.getPort(),
          udpSenderProperties.getMaxPacketSize());

  return createReporter(metrics, remoteReporter, udpSender);
}
 
Example #7
Source File: TraceBehaviorTest.java    From tchannel-java with MIT License 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    reporter = new InMemoryReporter();
    Sampler sampler = new ConstSampler(false);
    Reporter compositeReporter = new CompositeReporter(reporter, new LoggingReporter());
    tracer = new JaegerTracer.Builder(SERVER_NAME).withSampler(sampler).withReporter(compositeReporter).build();

    server = new Server("127.0.0.1", tracer);
    server.start();
    tchannel = server.tchannel;
    traceBehavior = server.traceBehavior;
}
 
Example #8
Source File: ActivityTracingWithSplitTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Before
public void before() throws Exception {

    activityEvents = new ArrayList<>();

    Tracer tracer = new JaegerTracer.Builder(getClass().getName()).withReporter(new Reporter() {
        @Override
        public void report(JaegerSpan span) {
            activityEvents.add(span);
        }

        @Override
        public void close() {
            // no resource to dispose
        }
    }).withSampler(new ConstSampler(true)).build();

    final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class),
        Arrays.asList(new TracingActivityTrackingPolicyFactory(tracer))) {

        @Override
        protected Integration loadIntegration() {
            return newIntegration(
                new Step.Builder()
                    .id("source")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("direct")
                            .putConfiguredProperty("name", "start")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .stepKind(StepKind.split)
                    .build(),
                new Step.Builder()
                    .id("step-1")
                    .stepKind(StepKind.log)
                    .putConfiguredProperty("contextLoggingEnabled", "true")
                    .putConfiguredProperty("customText", "Log me baby one more time").build(),
                new Step.Builder()
                    .id("step-2")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("class")
                            .putConfiguredProperty("beanName", TestBean.class.getName())
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .id("step-3")
                    .stepKind(StepKind.log)
                    .putConfiguredProperty("contextLoggingEnabled", "true")
                    .putConfiguredProperty("customText", "Log me baby one more time").build(),
                new Step.Builder()
                    .id("step-4")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("mock")
                            .putConfiguredProperty("name", "end")
                            .build())
                        .build())
                    .build());
        }
    };

    context = new DefaultCamelContext();
    context.setUuidGenerator(KeyGenerator::createKey);
    context.addLogListener(new TracingLogListener(tracer));
    context.addInterceptStrategy(new TracingInterceptStrategy(tracer));
    context.addRoutes(routeBuilder);
    context.getShutdownStrategy().setTimeout(1);
    context.start();

    dumpRoutes(context, routeBuilder.getRouteCollection());
}
 
Example #9
Source File: ReporterAppender.java    From java-spring-jaeger with Apache License 2.0 2 votes vote down vote up
/**
 * Provides the ability to add custom Reporters other than the ones that are auto-configured based
 * on the configuration Implementation should only add reporters to the collection
 */
void append(Collection<Reporter> reporters);