io.jaegertracing.Configuration.CodecConfiguration Java Examples

The following examples show how to use io.jaegertracing.Configuration.CodecConfiguration. 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: 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 #2
Source File: ImplementationsJFRTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
public void jaegerB3() throws IOException {
	System.setProperty(JAEGER_SAMPLER_TYPE, "const");
	System.setProperty(JAEGER_SAMPLER_PARAM, "1");
	System.setProperty(JAEGER_AGENT_HOST, "localhost");
	System.setProperty(JAEGER_AGENT_PORT, "6831");
	System.setProperty(JAEGER_PROPAGATION, "B3");

	Tracer jaegerTracer = new io.jaegertracing.Configuration("test").withSampler(SamplerConfiguration.fromEnv())
			.withCodec(CodecConfiguration.fromEnv()).withReporter(ReporterConfiguration.fromEnv()).getTracer();
	innerTest(jaegerTracer);
}
 
Example #3
Source File: ImplementationsJFRTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
public void jaegerUber() throws IOException {
	System.setProperty(JAEGER_SAMPLER_TYPE, "const");
	System.setProperty(JAEGER_SAMPLER_PARAM, "1");
	System.setProperty(JAEGER_AGENT_HOST, "localhost");
	System.setProperty(JAEGER_AGENT_PORT, "6831");
	System.setProperty(JAEGER_PROPAGATION, "JAEGER");

	Tracer jaegerTracer = new io.jaegertracing.Configuration("test").withSampler(SamplerConfiguration.fromEnv())
			.withCodec(CodecConfiguration.fromEnv()).withReporter(ReporterConfiguration.fromEnv()).getTracer();
	innerTest(jaegerTracer);
}
 
Example #4
Source File: ImplementationsJFRTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
public void jaegerB3() throws IOException {
	System.setProperty(JAEGER_SAMPLER_TYPE, "const");
	System.setProperty(JAEGER_SAMPLER_PARAM, "1");
	System.setProperty(JAEGER_AGENT_HOST, "localhost");
	System.setProperty(JAEGER_AGENT_PORT, "6831");
	System.setProperty(JAEGER_PROPAGATION, "B3");

	Tracer jaegerTracer = new io.jaegertracing.Configuration("test").withSampler(SamplerConfiguration.fromEnv())
			.withCodec(CodecConfiguration.fromEnv()).withReporter(ReporterConfiguration.fromEnv()).getTracer();
	innerTest(jaegerTracer);
}
 
Example #5
Source File: ImplementationsJFRTest.java    From java-jfr-tracer with Apache License 2.0 5 votes vote down vote up
@Test
public void jaegerUber() throws IOException {
	System.setProperty(JAEGER_SAMPLER_TYPE, "const");
	System.setProperty(JAEGER_SAMPLER_PARAM, "1");
	System.setProperty(JAEGER_AGENT_HOST, "localhost");
	System.setProperty(JAEGER_AGENT_PORT, "6831");
	System.setProperty(JAEGER_PROPAGATION, "JAEGER");

	Tracer jaegerTracer = new io.jaegertracing.Configuration("test").withSampler(SamplerConfiguration.fromEnv())
			.withCodec(CodecConfiguration.fromEnv()).withReporter(ReporterConfiguration.fromEnv()).getTracer();
	innerTest(jaegerTracer);
}
 
Example #6
Source File: JaegerInitializer.java    From thorntail with Apache License 2.0 4 votes vote down vote up
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
    ServletContext sc = servletContextEvent.getServletContext();

    String serviceName = getProperty(sc, JAEGER_SERVICE_NAME);
    if (serviceName == null || serviceName.isEmpty()) {
        logger.warn("No Service Name set. Using default. Please change it.");
        serviceName = "thorntail/unknown";
    }

    Configuration configuration = new Configuration(serviceName)
            .withSampler(
                    new Configuration.SamplerConfiguration()
                            .withType(
                                    getProperty(sc, JAEGER_SAMPLER_TYPE))
                            .withParam(
                                    getPropertyAsNumber(sc, JAEGER_SAMPLER_PARAM))
                            .withManagerHostPort(
                                    getProperty(sc, JAEGER_SAMPLER_MANAGER_HOST_PORT)))
            .withReporter(
                    new ReporterConfiguration()
                            .withLogSpans(
                                    getPropertyAsBoolean(sc, JAEGER_REPORTER_LOG_SPANS))
                            .withSender(
                                    new SenderConfiguration()
                                            .withAuthUsername(getProperty(sc, JAEGER_USER))
                                            .withAuthPassword(getProperty(sc, JAEGER_PASSWORD))
                                            .withAgentHost(getProperty(sc, JAEGER_AGENT_HOST))
                                            .withAgentPort(getPropertyAsInt(sc, JAEGER_AGENT_PORT)))
                            .withFlushInterval(
                                    getPropertyAsInt(sc, JAEGER_REPORTER_FLUSH_INTERVAL))
                            .withMaxQueueSize(
                                    getPropertyAsInt(sc, JAEGER_REPORTER_MAX_QUEUE_SIZE)
                            )
            );

    String remoteEndpoint = getProperty(sc, JAEGER_ENDPOINT);
    if (remoteEndpoint != null && remoteEndpoint.trim().length() > 0) {
        configuration.getReporter()
                .withSender(new SenderConfiguration()
                                    .withEndpoint(remoteEndpoint));
    }

    String enableB3HeaderPropagation = getProperty(sc, "enableB3HeaderPropagation");
    if (enableB3HeaderPropagation != null && Boolean.parseBoolean(enableB3HeaderPropagation)) {
        logger.info("Enabling B3 Header Propagation for Jaeger");
        CodecConfiguration codecConfiguration = new CodecConfiguration();
        codecConfiguration.withCodec(Builtin.HTTP_HEADERS, new B3TextMapCodec.Builder().build());
        codecConfiguration.withCodec(Builtin.TEXT_MAP, new B3TextMapCodec.Builder().build());
        configuration.withCodec(codecConfiguration);
    }

    GlobalTracer.register(configuration.getTracer());
}