阿男的小窝

View the Project on GitHub

Jersey中Tracing的功能分析

和TracingLogger有关的classes:

$ grep -rl 'TracingLogger' * | grep java$ | grep -v test | grep -v bundles
core-common/src/main/java/org/glassfish/jersey/message/internal/ReaderInterceptorExecutor.java
core-common/src/main/java/org/glassfish/jersey/message/internal/WriterInterceptorExecutor.java
core-common/src/main/java/org/glassfish/jersey/message/internal/MsgTraceEvent.java
core-common/src/main/java/org/glassfish/jersey/message/internal/TracingAwarePropertiesDelegate.java
core-common/src/main/java/org/glassfish/jersey/message/internal/MessageBodyFactory.java
core-common/src/main/java/org/glassfish/jersey/message/internal/InterceptorExecutor.java
core-common/src/main/java/org/glassfish/jersey/message/internal/TracingInfo.java
core-common/src/main/java/org/glassfish/jersey/message/internal/TracingLogger.java
core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java
core-server/src/main/java/org/glassfish/jersey/server/TracingConfig.java
core-server/src/main/java/org/glassfish/jersey/server/internal/ServerTraceEvent.java
core-server/src/main/java/org/glassfish/jersey/server/internal/routing/RoutingStage.java
core-server/src/main/java/org/glassfish/jersey/server/internal/routing/UriRoutingContext.java
core-server/src/main/java/org/glassfish/jersey/server/internal/routing/PathMatchingRouter.java
core-server/src/main/java/org/glassfish/jersey/server/TracingUtils.java
core-server/src/main/java/org/glassfish/jersey/server/ContainerFilteringStage.java
core-server/src/main/java/org/glassfish/jersey/server/model/internal/AbstractJavaResourceMethodDispatcher.java
ext/mvc-jsp/src/main/java/org/glassfish/jersey/server/mvc/jsp/JspTemplateProcessor.java

下面是ServerRuntime里面和TracingLogger相关的内容:

$ grep -rn 'tracingLogger' ./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:374:        private final TracingLogger tracingLogger;
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:380:            this.tracingLogger = TracingLogger.getInstance(processingContext.request());
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:546:                    final long timestamp = tracingLogger.timestamp(ServerTraceEvent.EXCEPTION_MAPPING);
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:554:                            if (tracingLogger.isLogEnabled(ServerTraceEvent.EXCEPTION_MAPPING)) {
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:555:                                tracingLogger.logDuration(ServerTraceEvent.EXCEPTION_MAPPING,
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:631:                tracingLogger.log(ServerTraceEvent.FINISHED, response.getStatusInfo());
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:632:                tracingLogger.flush(response.getHeaders());
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:678:                tracingLogger.log(ServerTraceEvent.FINISHED, response.getStatusInfo());
./core-server/src/main/java/org/glassfish/jersey/server/ServerRuntime.java:679:                tracingLogger.flush(response.getHeaders());
$ grep -rn 'tracingLogger' core-server/src/main/java/org/glassfish/jersey/server/model/internal/AbstractJavaResourceMethodDispatcher.java
core-server/src/main/java/org/glassfish/jersey/server/model/internal/AbstractJavaResourceMethodDispatcher.java:144:                    final TracingLogger tracingLogger = TracingLogger.getInstance(containerRequest);
core-server/src/main/java/org/glassfish/jersey/server/model/internal/AbstractJavaResourceMethodDispatcher.java:145:                    final long timestamp = tracingLogger.timestamp(ServerTraceEvent.METHOD_INVOKE);
core-server/src/main/java/org/glassfish/jersey/server/model/internal/AbstractJavaResourceMethodDispatcher.java:183:                        tracingLogger.logDuration(ServerTraceEvent.METHOD_INVOKE, timestamp, resource, method);

结论:Jersey的Tracing功能实现散布在项目的各个组件当中,是一个细致的工作。