@SuppressWarnings("unchecked") private <T> MessageBodyReader<T> _getMessageBodyReader(final Class<T> c, final Type t, final Annotation[] as, final MediaType mediaType, final MediaType lookup, final PropertiesDelegate propertiesDelegate) { final List<MessageBodyReader> readers = readersCache.get(lookup); if (readers == null) { return null; } final TracingLogger tracingLogger = TracingLogger.getInstance(propertiesDelegate); MessageBodyReader<T> selected = null; final Iterator<MessageBodyReader> iterator = readers.iterator(); while (iterator.hasNext()) { final MessageBodyReader p = iterator.next(); if (isReadable(p, c, t, as, mediaType)) { selected = (MessageBodyReader<T>) p; tracingLogger.log(MsgTraceEvent.MBR_SELECTED, selected); break; } tracingLogger.log(MsgTraceEvent.MBR_NOT_READABLE, p); } if (tracingLogger.isLogEnabled(MsgTraceEvent.MBR_SKIPPED)) { while (iterator.hasNext()) { final MessageBodyReader p = iterator.next(); tracingLogger.log(MsgTraceEvent.MBR_SKIPPED, p); } } return selected; }
writerInterceptors, injectionManager); final TracingLogger tracingLogger = TracingLogger.getInstance(propertiesDelegate); final long timestamp = tracingLogger.timestamp(MsgTraceEvent.WI_SUMMARY); tracingLogger.logDuration(MsgTraceEvent.WI_SUMMARY, timestamp, executor.getProcessedCount());
/** * According to configuration/request header it initialize {@link TracingLogger} and put it to the request properties. * * @param type application-wide tracing configuration type. * @param appThreshold application-wide tracing level threshold. * @param containerRequest request instance to get runtime properties to store {@link TracingLogger} instance to * if tracing support is enabled for the request. */ public static void initTracingSupport(TracingConfig type, TracingLogger.Level appThreshold, ContainerRequest containerRequest) { final TracingLogger tracingLogger; if (isTracingSupportEnabled(type, containerRequest)) { tracingLogger = TracingLogger.create( getTracingThreshold(appThreshold, containerRequest), getTracingLoggerNameSuffix(containerRequest)); } else { tracingLogger = TracingLogger.empty(); } containerRequest.setProperty(TracingLogger.PROPERTY_NAME, tracingLogger); }
@Override public final Response dispatch(Object resource, ContainerRequest request) throws ProcessingException { Response response = null; try { response = doDispatch(resource, request); } finally { TracingLogger.getInstance(request).log(ServerTraceEvent.DISPATCH_RESPONSE, response); } return response; }
/** * Tracing support - log invocation of interceptor BEFORE context.proceed() call. * * @param interceptor invoked interceptor * @param event event type to be tested */ protected final void traceBefore(final T interceptor, final TracingLogger.Event event) { if (tracingLogger.isLogEnabled(event)) { if ((lastTracedInterceptor != null) && (interceptor != null)) { tracingLogger.logDuration(event, lastTracedInterceptor.getTimestamp(), lastTracedInterceptor.getInterceptor()); } lastTracedInterceptor = new InterceptorTimestampPair<T>(interceptor, System.nanoTime()); } }
@Override public void pushMatchedRuntimeResource(final RuntimeResource runtimeResource) { if (tracingLogger.isLogEnabled(ServerTraceEvent.MATCH_RUNTIME_RESOURCE)) { tracingLogger.log(ServerTraceEvent.MATCH_RUNTIME_RESOURCE, runtimeResource.getResources().get(0).getPath(), runtimeResource.getResources().get(0).getPathPattern().getRegex(), matchResults.peek().group() .substring(0, matchResults.peek().group().length() - getFinalMatchingGroup().length()), matchResults.peek().group()); } this.matchedRuntimeResources.push(runtimeResource); }
processingContext.triggerEvent(RequestEvent.Type.RESP_FILTERS_START); final long timestamp = tracingLogger.timestamp(ServerTraceEvent.RESPONSE_FILTER_SUMMARY); int processedCount = 0; try { for (ContainerResponseFilter filter : sortedResponseFilters) { final long filterTimestamp = tracingLogger.timestamp(ServerTraceEvent.RESPONSE_FILTER); try { filter.filter(request, responseContext); } finally { processedCount++; tracingLogger.logDuration(ServerTraceEvent.RESPONSE_FILTER, filterTimestamp, filter); tracingLogger.logDuration(ServerTraceEvent.RESPONSE_FILTER_SUMMARY, timestamp, processedCount);
final long timestamp = tracingLogger.timestamp(ServerTraceEvent.EXCEPTION_MAPPING); final ExceptionMapper mapper = runtime.exceptionMappers.findMapping(throwable); if (mapper != null) { final Response mappedResponse = mapper.toResponse(throwable); if (tracingLogger.isLogEnabled(ServerTraceEvent.EXCEPTION_MAPPING)) { tracingLogger.logDuration(ServerTraceEvent.EXCEPTION_MAPPING, timestamp, mapper, throwable, throwable.getLocalizedMessage(), mappedResponse != null ? mappedResponse.getStatusInfo() : "-no-response-");
@Override public void pushMatchedResource(final Object resource) { tracingLogger.log(ServerTraceEvent.MATCH_RESOURCE, resource); matchedResources.push(resource); }
/** * Injection constructor. * * @param requestContext request reference. */ public UriRoutingContext(final ContainerRequest requestContext) { this.requestContext = requestContext; this.tracingLogger = TracingLogger.getInstance(requestContext); }
@Override public void pushMatchedRuntimeResource(final RuntimeResource runtimeResource) { if (tracingLogger.isLogEnabled(ServerTraceEvent.MATCH_RUNTIME_RESOURCE)) { tracingLogger.log(ServerTraceEvent.MATCH_RUNTIME_RESOURCE, runtimeResource.getResources().get(0).getPath(), runtimeResource.getResources().get(0).getPathPattern().getRegex(), matchResults.peek().group() .substring(0, matchResults.peek().group().length() - getFinalMatchingGroup().length()), matchResults.peek().group()); } this.matchedRuntimeResources.push(runtimeResource); }
processingContext.triggerEvent(RequestEvent.Type.RESP_FILTERS_START); final long timestamp = tracingLogger.timestamp(ServerTraceEvent.RESPONSE_FILTER_SUMMARY); int processedCount = 0; try { for (ContainerResponseFilter filter : sortedResponseFilters) { final long filterTimestamp = tracingLogger.timestamp(ServerTraceEvent.RESPONSE_FILTER); try { filter.filter(request, responseContext); } finally { processedCount++; tracingLogger.logDuration(ServerTraceEvent.RESPONSE_FILTER, filterTimestamp, filter); tracingLogger.logDuration(ServerTraceEvent.RESPONSE_FILTER_SUMMARY, timestamp, processedCount);
/** * Tracing support - log invocation of interceptor AFTER context.proceed() call. * * @param interceptor invoked interceptor * @param event event type to be tested */ protected final void traceAfter(final T interceptor, final TracingLogger.Event event) { if (tracingLogger.isLogEnabled(event)) { if ((lastTracedInterceptor != null) && (lastTracedInterceptor.getInterceptor() != null)) { tracingLogger.logDuration(event, lastTracedInterceptor.getTimestamp(), interceptor); } lastTracedInterceptor = new InterceptorTimestampPair<T>(interceptor, System.nanoTime()); } }
final long timestamp = tracingLogger.timestamp(ServerTraceEvent.EXCEPTION_MAPPING); final ExceptionMapper mapper = runtime.exceptionMappers.findMapping(throwable); if (mapper != null) { final Response mappedResponse = mapper.toResponse(throwable); if (tracingLogger.isLogEnabled(ServerTraceEvent.EXCEPTION_MAPPING)) { tracingLogger.logDuration(ServerTraceEvent.EXCEPTION_MAPPING, timestamp, mapper, throwable, throwable.getLocalizedMessage(), mappedResponse != null ? mappedResponse.getStatusInfo() : "-no-response-");
@Override public final Response dispatch(Object resource, ContainerRequest request) throws ProcessingException { Response response = null; try { response = doDispatch(resource, request); } finally { TracingLogger.getInstance(request).log(ServerTraceEvent.DISPATCH_RESPONSE, response); } return response; }
@Override public void pushMatchedResource(final Object resource) { tracingLogger.log(ServerTraceEvent.MATCH_RESOURCE, resource); matchedResources.push(resource); }
/** * Injection constructor. * * @param requestContext request reference. */ public UriRoutingContext(final ContainerRequest requestContext) { this.requestContext = requestContext; this.tracingLogger = TracingLogger.getInstance(requestContext); }
@SuppressWarnings("unchecked") private <T> MessageBodyWriter<T> _getMessageBodyWriter(final Class<T> c, final Type t, final Annotation[] as, final MediaType mediaType, final MediaType lookup, final PropertiesDelegate propertiesDelegate) { final List<MessageBodyWriter> writers = writersCache.get(lookup); if (writers == null) { return null; } final TracingLogger tracingLogger = TracingLogger.getInstance(propertiesDelegate); MessageBodyWriter<T> selected = null; final Iterator<MessageBodyWriter> iterator = writers.iterator(); while (iterator.hasNext()) { final MessageBodyWriter p = iterator.next(); if (isWriteable(p, c, t, as, mediaType)) { selected = (MessageBodyWriter<T>) p; tracingLogger.log(MsgTraceEvent.MBW_SELECTED, selected); break; } tracingLogger.log(MsgTraceEvent.MBW_NOT_WRITEABLE, p); } if (tracingLogger.isLogEnabled(MsgTraceEvent.MBW_SKIPPED)) { while (iterator.hasNext()) { final MessageBodyWriter p = iterator.next(); tracingLogger.log(MsgTraceEvent.MBW_SKIPPED, p); } } return selected; }