Search in sources :

Example 1 with OkHttpSender

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;
    }
}
Also used : OkHttpSender(zipkin2.reporter.okhttp3.OkHttpSender) ThreadLocalScopeManager(io.opentracing.util.ThreadLocalScopeManager) BraveTracer(brave.opentracing.BraveTracer) Tracer(io.opentracing.Tracer) GlobalTracer(io.opentracing.util.GlobalTracer) Reporter(io.opentracing.contrib.reporter.Reporter) AsyncReporter(zipkin2.reporter.AsyncReporter) TracerR(io.opentracing.contrib.reporter.TracerR)

Aggregations

BraveTracer (brave.opentracing.BraveTracer)1 Tracer (io.opentracing.Tracer)1 Reporter (io.opentracing.contrib.reporter.Reporter)1 TracerR (io.opentracing.contrib.reporter.TracerR)1 GlobalTracer (io.opentracing.util.GlobalTracer)1 ThreadLocalScopeManager (io.opentracing.util.ThreadLocalScopeManager)1 AsyncReporter (zipkin2.reporter.AsyncReporter)1 OkHttpSender (zipkin2.reporter.okhttp3.OkHttpSender)1