use of org.jboss.resteasy.tracing.RESTEasyTracingLogger in project resteasy by resteasy.
the class ClientInvocation method initTracingSupport.
private void initTracingSupport() {
final RESTEasyTracingLogger tracingLogger;
if (RESTEasyTracingLogger.isTracingConfigALL(configuration)) {
tracingLogger = RESTEasyTracingLogger.create(this.toString(), configuration, this.toString());
} else {
tracingLogger = RESTEasyTracingLogger.empty();
}
this.tracingLogger = tracingLogger;
}
use of org.jboss.resteasy.tracing.RESTEasyTracingLogger in project resteasy by resteasy.
the class ServerResponseWriter method executeFilters.
private static void executeFilters(BuiltResponse jaxrsResponse, HttpRequest request, HttpResponse response, ResteasyProviderFactory providerFactory, ResourceMethodInvoker method, Consumer<Throwable> onComplete, RunnableWithIOException continuation) throws IOException {
ContainerResponseFilter[] responseFilters = null;
if (method != null) {
responseFilters = method.getResponseFilters();
} else {
responseFilters = providerFactory.getContainerResponseFilterRegistry().postMatch(null, null);
}
if (responseFilters != null) {
ResponseContainerRequestContext requestContext = new ResponseContainerRequestContext(request);
ContainerResponseContextImpl responseContext = new ContainerResponseContextImpl(request, response, jaxrsResponse, requestContext, responseFilters, onComplete, continuation);
RESTEasyTracingLogger logger = RESTEasyTracingLogger.getInstance(request);
final long timestamp = logger.timestamp("RESPONSE_FILTER_SUMMARY");
// filter calls the continuation
responseContext.filter();
logger.logDuration("RESPONSE_FILTER_SUMMARY", timestamp, responseFilters.length);
} else {
try {
continuation.run(onComplete);
} catch (Throwable t) {
onComplete.accept(t);
SynchronousDispatcher.rethrow(t);
}
}
}
use of org.jboss.resteasy.tracing.RESTEasyTracingLogger in project resteasy by resteasy.
the class SynchronousDispatcher method invoke.
/**
* Invoke and write response.
*
* @param request http request
* @param response http response
* @param invoker resource invoker
*/
public void invoke(HttpRequest request, HttpResponse response, ResourceInvoker invoker) {
RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request);
Response jaxrsResponse = null;
try {
request.getAsyncContext().initialRequestStarted();
jaxrsResponse = invoker.invoke(request, response);
request.getAsyncContext().initialRequestEnded();
tracingLogger.log("DISPATCH_RESPONSE", jaxrsResponse);
if (request.getAsyncContext().isSuspended()) {
/**
* Callback by the initial calling thread. This callback will probably do nothing in an asynchronous environment
* but will be used to simulate AsynchronousResponse in vanilla Servlet containers that do not support
* asychronous HTTP.
*/
request.getAsyncContext().getAsyncResponse().initialRequestThreadFinished();
// we're handing response asynchronously
jaxrsResponse = null;
}
} catch (CompletionException e) {
// logger.error("invoke() failed mapping exception", e);
writeException(request, response, e.getCause(), t -> {
});
return;
} catch (Exception e) {
// logger.error("invoke() failed mapping exception", e);
invoker.getMethodStatisticsLogger().incFailureCnt();
writeException(request, response, e, t -> {
});
return;
}
if (jaxrsResponse != null) {
writeResponse(request, response, jaxrsResponse);
}
}
use of org.jboss.resteasy.tracing.RESTEasyTracingLogger in project resteasy by resteasy.
the class SynchronousDispatcher method getInvoker.
public ResourceInvoker getInvoker(HttpRequest request) throws Failure {
LogMessages.LOGGER.pathInfo(request.getUri().getPath());
if (!request.isInitial()) {
throw new InternalServerErrorException(Messages.MESSAGES.isNotInitialRequest(request.getUri().getPath()));
}
ResourceInvoker invoker = registry.getResourceInvoker(request);
if (invoker == null) {
throw new NotFoundException(Messages.MESSAGES.unableToFindJaxRsResource(request.getUri().getPath()));
}
RESTEasyTracingLogger logger = RESTEasyTracingLogger.getInstance(request);
logger.log("MATCH_RESOURCE", invoker);
logger.log("MATCH_RESOURCE_METHOD", invoker.getMethod());
return invoker;
}
use of org.jboss.resteasy.tracing.RESTEasyTracingLogger in project resteasy by resteasy.
the class SynchronousDispatcher method execute.
/**
* Return a response wither from an invoke or exception handling.
*
* @param request http request
* @param response http response
* @param invoker resource invoker
* @return response
*/
public Response execute(HttpRequest request, HttpResponse response, ResourceInvoker invoker) {
Response jaxrsResponse = null;
try {
RESTEasyTracingLogger logger = RESTEasyTracingLogger.getInstance(request);
logger.log("DISPATCH_RESPONSE", jaxrsResponse);
request.getAsyncContext().initialRequestStarted();
jaxrsResponse = invoker.invoke(request, response);
request.getAsyncContext().initialRequestEnded();
if (request.getAsyncContext().isSuspended()) {
/**
* Callback by the initial calling thread. This callback will probably do nothing in an asynchronous environment
* but will be used to simulate AsynchronousResponse in vanilla Servlet containers that do not support
* asychronous HTTP.
*/
request.getAsyncContext().getAsyncResponse().initialRequestThreadFinished();
// we're handing response asynchronously
jaxrsResponse = null;
}
} catch (CompletionException e) {
// logger.error("invoke() failed mapping exception", e);
jaxrsResponse = new ExceptionHandler(providerFactory, unwrappedExceptions).handleException(request, e.getCause());
if (jaxrsResponse == null)
throw new UnhandledException(e.getCause());
} catch (Exception e) {
// logger.error("invoke() failed mapping exception", e);
jaxrsResponse = new ExceptionHandler(providerFactory, unwrappedExceptions).handleException(request, e);
if (jaxrsResponse == null)
throw new UnhandledException(e);
}
return jaxrsResponse;
}
Aggregations