use of fish.payara.nucleus.requesttracing.RequestTracingService in project Payara by payara.
the class JaxrsClientRequestTracingFilter method filter.
// After method invocation
@Override
public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
final PayaraTracingServices payaraTracingServices = new PayaraTracingServices();
final RequestTracingService requestTracing = payaraTracingServices.getRequestTracingService();
// If request tracing is enabled, and there's a trace actually in progress, add info about method
if (requestTracing != null && requestTracing.isRequestTracingEnabled() && shouldTrace(requestContext)) {
// Get the active span from the application's tracer instance
Span activeSpan = payaraTracingServices.getActiveTracer().scopeManager().activeSpan();
if (activeSpan == null) {
// This should really only occur when enabling request tracing due to the nature of the
// service not being enabled when making the request to enable it, and then
// obviously being enabled on the return. Any other entrance into here is likely a bug
// caused by a tracing context not being propagated.
Logger.getLogger(JaxrsClientRequestTracingFilter.class.getName()).log(Level.FINE, "activeScope in opentracing request tracing filter was null for {0}", responseContext);
return;
}
try {
// Get the response status and add it to the active span
StatusType statusInfo = responseContext.getStatusInfo();
activeSpan.setTag(Tags.HTTP_STATUS.getKey(), statusInfo.getStatusCode());
// If the response status is an error, add error info to the active span
if (statusInfo.getFamily() == Family.CLIENT_ERROR || statusInfo.getFamily() == Family.SERVER_ERROR) {
activeSpan.setTag(Tags.ERROR.getKey(), true);
activeSpan.log(Collections.singletonMap("event", "error"));
activeSpan.log(Collections.singletonMap("error.object", statusInfo.getFamily()));
}
} finally {
activeSpan.finish();
Object scopeObj = requestContext.getProperty(Scope.class.getName());
if (scopeObj != null && scopeObj instanceof Scope) {
try (Scope scope = (Scope) scopeObj) {
requestContext.removeProperty(Scope.class.getName());
}
}
}
}
}
use of fish.payara.nucleus.requesttracing.RequestTracingService in project Payara by payara.
the class FaultToleranceServiceImpl method postConstruct.
@PostConstruct
public void postConstruct() {
try {
events.register(this);
invocationManager = serviceLocator.getService(InvocationManager.class);
requestTracingService = serviceLocator.getService(RequestTracingService.class);
config = serviceLocator.getService(FaultToleranceServiceConfiguration.class);
InitialContext context = new InitialContext();
asyncExecutorService = (ManagedExecutorService) context.lookup(config.getManagedExecutorService());
delayExecutorService = (ManagedScheduledExecutorService) context.lookup(config.getManagedScheduledExecutorService());
} catch (NamingException namingException) {
throw new RuntimeException("Error initialising Fault Tolerance Service: could not perform lookup for configured managed-executor-service or managed-scheduled-executor-service.", namingException);
}
}
Aggregations