use of zipkin2.reporter.okhttp3.OkHttpSender in project carbon-apimgt by wso2.
the class ZipkinTracer method getTracer.
@Override
public Tracer getTracer(String serviceName) {
String hostname = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) != null ? configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_HOST) : TracingConstants.ZIPKIN_DEFAULT_HOST;
int port = configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.ZIPKIN_CONFIG_PORT)) : TracingConstants.ZIPKIN_DEFAULT_PORT;
boolean tracerLogEnabled = Boolean.parseBoolean(configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) : TracingConstants.DEFAULT_TRACER_LOG_ENABLED);
OkHttpSender sender = OkHttpSender.create("http://" + hostname + ":" + port + TracingConstants.ZIPKIN_API_CONTEXT);
Tracer tracer = BraveTracer.create(Tracing.newBuilder().localServiceName(serviceName).spanReporter(AsyncReporter.builder(sender).build()).propagationFactory(ExtraFieldPropagation.newFactory(B3Propagation.FACTORY, TracingConstants.REQUEST_ID)).build());
if (tracerLogEnabled) {
Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER));
Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager());
GlobalTracer.register(tracerR);
return tracerR;
} else {
GlobalTracer.register(tracer);
return tracer;
}
}
Aggregations