use of io.opentracing.Tracer in project wildfly-swarm by wildfly-swarm.
the class OpenTracingInitializer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
ServletContext servletContext = servletContextEvent.getServletContext();
String skipPatternAttribute = servletContext.getInitParameter(TracingFilter.SKIP_PATTERN);
if (null != skipPatternAttribute && !skipPatternAttribute.isEmpty()) {
servletContext.setAttribute(TracingFilter.SKIP_PATTERN, Pattern.compile(skipPatternAttribute));
}
logger.info("Registering Tracing Filter");
Dynamic filterRegistration = servletContext.addFilter("tracingFilter", new TracingFilter());
filterRegistration.setAsyncSupported(true);
filterRegistration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "*");
String skipParameter = servletContext.getInitParameter("skipOpenTracingResolver");
if (skipParameter != null && Boolean.parseBoolean(skipParameter)) {
logger.info("OpenTracing automatic resolution is being explicitly skipped.");
return;
}
if (GlobalTracer.isRegistered()) {
logger.info("A Tracer is already registered at the GlobalTracer. Skipping resolution via TraceResolver.");
return;
}
Tracer tracer = TracerResolver.resolveTracer();
if (null == tracer) {
logger.info("Could not get a valid OpenTracing Tracer from the classpath. Skipping.");
return;
}
logger.info(String.format("Registering %s as the OpenTracing Tracer", tracer.getClass().getName()));
GlobalTracer.register(tracer);
}
use of io.opentracing.Tracer in project wildfly by wildfly.
the class ResteasyClientTracingRegistrarProvider method configure.
@Override
public ClientBuilder configure(ClientBuilder clientBuilder, ExecutorService executorService) {
ResteasyClientBuilder resteasyClientBuilder = (ResteasyClientBuilder) clientBuilder;
Tracer tracer = CDI.current().select(Tracer.class).get();
return resteasyClientBuilder.executorService(new TracedExecutorService(executorService, tracer)).register(new SmallRyeClientTracingFeature(tracer));
}
use of io.opentracing.Tracer in project Payara by payara.
the class RemoteEjbClientIT method executeRemoteEjbMethodIT.
@Test
public void executeRemoteEjbMethodIT() throws NamingException {
Properties contextProperties = new Properties();
contextProperties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
contextProperties.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
contextProperties.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
Context context = new InitialContext(contextProperties);
EjbRemote ejb = (EjbRemote) context.lookup(String.format("java:global%sEjb", uri.getPath()));
Tracer tracer = GlobalTracer.get();
Span span = null;
try {
span = tracer.buildSpan("ExecuteEjb").start();
tracer.activateSpan(span);
span.setBaggageItem("Wibbles", "Wobbles");
String baggageItems = ejb.annotatedMethod();
Assert.assertTrue("Baggage items didn't match, received: " + baggageItems, baggageItems.contains("\nWibbles : Wobbles\n"));
span.setBaggageItem("Nibbles", "Nobbles");
baggageItems = ejb.nonAnnotatedMethod();
Assert.assertTrue("Baggage items didn't match, received: " + baggageItems, baggageItems.contains("Wibbles : Wobbles") && baggageItems.contains("Nibbles : Nobbles"));
span.setBaggageItem("Bibbles", "Bobbles");
baggageItems = ejb.shouldNotBeTraced();
Assert.assertTrue("Baggage items didn't match, received: " + baggageItems, baggageItems.contains("Wibbles : Wobbles") && baggageItems.contains("Nibbles : Nobbles") && baggageItems.contains("Bibbles : Bobbles"));
baggageItems = ejb.editBaggageItems();
Assert.assertTrue("Baggage items didn't match, received: " + baggageItems, baggageItems.contains("Wibbles : Wabbles") && baggageItems.contains("Nibbles : Nabbles") && baggageItems.contains("Bibbles : Babbles"));
} finally {
if (span != null) {
span.finish();
}
}
}
use of io.opentracing.Tracer in project Payara by payara.
the class SafeProperties method addEjbMethodTraceLog.
private void addEjbMethodTraceLog(CallFlowInfo info, boolean callEnter) {
if (openTracingService.isEnabled()) {
Tracer tracer = openTracingService.getTracer(openTracingService.getApplicationName(invocationManager));
RequestTraceSpanLog spanLog = constructEjbMethodSpanLog(info, callEnter);
if (tracer != null) {
Span span = tracer.activeSpan();
if (span != null) {
span.log(spanLog.getTimeMillis(), spanLog.getLogEntries());
} else {
// Traces started in the pre-OpenTracing style won't have an active span, so just attempt to add as
// is to thread local trace if there is one
requestTracingService.addSpanLog(spanLog);
}
} else {
// If we couldn't get a tracer here, it's because we couldn't get a name from the invocation manager.
// In such a case, just try to add the span log to the currently active thread local request trace
requestTracingService.addSpanLog(spanLog);
}
}
}
use of io.opentracing.Tracer in project Payara by payara.
the class OpenTracingService method createTracer.
private synchronized Tracer createTracer(String applicationName) {
// Does this NEED to be synchronised? Tracers don't store state, and Scopes are ThreadLocal
// Double-checked locking - potentially naughty
Tracer tracer = tracers.computeIfAbsent(applicationName, (appName) -> {
Tracer newTracer = null;
// Check which type of Tracer to create
try {
// See if an alternate implementation of Tracer is available in a library.
ServiceLoader<Tracer> tracerLoader = ServiceLoader.load(Tracer.class);
Iterator<Tracer> loadedTracer = tracerLoader.iterator();
if (loadedTracer.hasNext()) {
newTracer = loadedTracer.next();
}
} catch (NoClassDefFoundError ex) {
logger.log(Level.SEVERE, "Unable to find Tracer implementation", ex);
}
if (newTracer == null) {
newTracer = new fish.payara.opentracing.tracer.Tracer(appName, getRequestTracingService());
}
return newTracer;
});
return tracer;
}
Aggregations