use of zipkin2.reporter.Reporter 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;
}
}
use of zipkin2.reporter.Reporter in project brave by openzipkin.
the class TracerTest method toString_withSpanReporter.
@Test
public void toString_withSpanReporter() {
tracer = Tracing.newBuilder().addSpanHandler(new SpanHandler() {
@Override
public boolean end(TraceContext context, MutableSpan span, Cause cause) {
return true;
}
@Override
public String toString() {
return "MyHandler";
}
}).spanReporter(new Reporter<zipkin2.Span>() {
@Override
public void report(zipkin2.Span span) {
}
@Override
public String toString() {
return "MyReporter";
}
}).build().tracer();
assertThat(tracer).hasToString("Tracer{spanHandler=[MyHandler, MyReporter]}");
}
Aggregations