in fractions/jaeger/src/main/java/org/wildfly/swarm/jaeger/deployment/JaegerInitializer.java [56:108]
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());
}