Java Code Examples for org.apache.camel.opentracing.OpenTracingTracer#init()

The following examples show how to use org.apache.camel.opentracing.OpenTracingTracer#init() . 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: OpenTracingAutoConfiguration.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
@Bean(initMethod = "", destroyMethod = "")
// Camel handles the lifecycle of this bean
@ConditionalOnMissingBean(OpenTracingTracer.class)
OpenTracingTracer openTracingEventNotifier(CamelContext camelContext,
                    OpenTracingConfigurationProperties config) {
    OpenTracingTracer ottracer = new OpenTracingTracer();
    if (tracer != null) {
        ottracer.setTracer(tracer);
    }
    if (config.getExcludePatterns() != null) {
        ottracer.setExcludePatterns(config.getExcludePatterns());
    }
    if (config.getEncoding() != null) {
        ottracer.setEncoding(config.getEncoding().booleanValue());
    }
    ottracer.init(camelContext);

    return ottracer;
}
 
Example 2
Source File: TracingContextCustomizer.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public void apply(CamelContext camelContext) {
    ObjectHelper.notNull(serviceName, "service-name");

    Tracer tracer = new Configuration(camelContext.getName())
        .withServiceName(serviceName)
        .withTracerTags(tags != null ? tags : Collections.emptyMap())
        .withReporter(reporter)
        .withSampler(sampler)
        .getTracer();

    OpenTracingTracer openTracingTracer = new OpenTracingTracer();
    openTracingTracer.setTracer(tracer);
    openTracingTracer.init(camelContext);
}
 
Example 3
Source File: CamelAgentIntercept.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
public static void enter(final Object thiz) {
  final DefaultCamelContext context = (DefaultCamelContext)thiz;
  if (state.containsKey(context))
    return;

  final OpenTracingTracer tracer = new OpenTracingTracer();
  tracer.init(context);
  state.put(context, null);
}
 
Example 4
Source File: OpenTracingIntegrationTest.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Test
public void testOpenTracingComponent() throws Exception {
    CamelContext camelctx = new DefaultCamelContext();

    OpenTracingTracer tracer = new OpenTracingTracer();
    tracer.init(camelctx);

    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("seda:dude").routeId("dude")
            .log("routing at ${routeId}")
            .delay(simple("${random(1000,2000)}"));
        }
    });

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        NotifyBuilder notify = new NotifyBuilder(camelctx).whenDone(5).create();

        for (int i = 0; i < 5; i++) {
            template.sendBody("seda:dude", "Hello World");
        }

        Assert.assertTrue(notify.matches(30, TimeUnit.SECONDS));
    } finally {
        camelctx.close();
    }
}