use of io.opentracing.contrib.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 io.opentracing.contrib.reporter.Reporter in project carbon-apimgt by wso2.
the class LogTracer method getTracer.
@Override
public Tracer getTracer(String serviceName) {
boolean logEnabled = Boolean.valueOf(configuration.getFirstProperty(TracingConstants.LOG_ENABLED));
if (logEnabled) {
Tracer tracer = NoopTracerFactory.create();
Reporter reporter = new TracingReporter(LogFactory.getLog(TracingConstants.TRACER));
Tracer tracerR = new TracerR(tracer, reporter, new ThreadLocalScopeManager());
GlobalTracer.register(tracerR);
return tracerR;
}
return null;
}
use of io.opentracing.contrib.reporter.Reporter in project carbon-apimgt by wso2.
the class JaegerTracer method getTracer.
@Override
public Tracer getTracer(String serviceName) {
String hostname = configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_HOST) != null ? configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_HOST) : TracingConstants.JAEGER_DEFAULT_HOST;
int port = configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_PORT) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.JAEGER_CONFIG_PORT)) : TracingConstants.JAEGER_DEFAULT_PORT;
String samplerType = configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_TYPE) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_TYPE) : TracingConstants.DEFAULT_SAMPLER_TYPE;
float samplerParam = configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_PARAM) != null ? Float.parseFloat(configuration.getFirstProperty(TracingConstants.CONFIG_SAMPLER_PARAM)) : TracingConstants.DEFAULT_SAMPLER_PARAM;
int reporterFlushInterval = configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_FLUSH_INTERVAL) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_FLUSH_INTERVAL)) : TracingConstants.DEFAULT_REPORTER_FLUSH_INTERVAL;
int reporterBufferSize = configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_BUFFER_SIZE) != null ? Integer.parseInt(configuration.getFirstProperty(TracingConstants.CONFIG_REPORTER_BUFFER_SIZE)) : TracingConstants.DEFAULT_REPORTER_BUFFER_SIZE;
boolean tracerLogEnabled = Boolean.parseBoolean(configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) != null ? configuration.getFirstProperty(TracingConstants.CONFIG_TRACER_LOG_ENABLED) : TracingConstants.DEFAULT_TRACER_LOG_ENABLED);
Configuration.SamplerConfiguration samplerConfig = new Configuration.SamplerConfiguration().withType(samplerType).withParam(samplerParam);
Configuration.SenderConfiguration senderConfig = new Configuration.SenderConfiguration().withAgentHost(hostname).withAgentPort(port);
Configuration.ReporterConfiguration reporterConfig = new Configuration.ReporterConfiguration().withLogSpans(true).withFlushInterval(reporterFlushInterval).withMaxQueueSize(reporterBufferSize).withSender(senderConfig);
Tracer tracer = new Configuration(serviceName).withSampler(samplerConfig).withReporter(reporterConfig).getTracer();
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