diff --git a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorder.java b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorder.java index 76a143a4d8bd..5b3632f1b4b5 100644 --- a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorder.java +++ b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorder.java @@ -21,6 +21,8 @@ import com.navercorp.pinpoint.bootstrap.logging.PLogger; import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; +import java.util.Objects; + /** * @author jaehong.kim */ @@ -31,7 +33,7 @@ public class HttpStatusCodeRecorder { private final HttpStatusCodeErrors errors; public HttpStatusCodeRecorder(final HttpStatusCodeErrors errors) { - this.errors = errors; + this.errors = Objects.requireNonNull(errors, "errors"); } public void record(final SpanRecorder spanRecorder, final int statusCode) { @@ -40,7 +42,7 @@ public void record(final SpanRecorder spanRecorder, final int statusCode) { return; } - if (!this.errors.isHttpStatusCode(statusCode)) { + if (Boolean.FALSE == this.errors.isHttpStatusCode(statusCode)) { if (isDebug) { logger.debug("Out of range HTTP status code. statusCode={}", statusCode); } diff --git a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListener.java b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListener.java index e1a753085621..6ea8d3389de2 100644 --- a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListener.java +++ b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListener.java @@ -55,8 +55,6 @@ public class ServletRequestListener { private final ProxyRequestRecorder proxyRequestRecorder; - private final boolean recordStatusCode; - public ServletRequestListener(final ServiceType serviceType, final TraceContext traceContext, final RequestAdaptor requestAdaptor, @@ -65,8 +63,7 @@ public ServletRequestListener(final ServiceType serviceType, final ParameterRecorder parameterRecorder, final ProxyRequestRecorder proxyRequestRecorder, final ServerRequestRecorder serverRequestRecorder, - final HttpStatusCodeRecorder httpStatusCodeRecorder, - final boolean recordStatusCode) { + final HttpStatusCodeRecorder httpStatusCodeRecorder) { this.serviceType = Objects.requireNonNull(serviceType, "serviceType"); this.traceContext = Objects.requireNonNull(traceContext, "traceContext"); this.requestAdaptor = Objects.requireNonNull(requestAdaptor, "requestAdaptor"); @@ -76,7 +73,6 @@ public ServletRequestListener(final ServiceType serviceType, this.parameterRecorder = Objects.requireNonNull(parameterRecorder, "parameterRecorder"); this.serverRequestRecorder = Objects.requireNonNull(serverRequestRecorder, "serverRequestRecorder"); this.httpStatusCodeRecorder = Objects.requireNonNull(httpStatusCodeRecorder, "httpStatusCodeRecorder"); - this.recordStatusCode = recordStatusCode; this.traceContext.cacheApi(SERVLET_SYNC_METHOD_DESCRIPTOR); } @@ -141,11 +137,8 @@ public void destroyed(REQ request, final Throwable throwable, final int statusCo return; } - if (this.recordStatusCode) { - this.httpStatusCodeRecorder.record(trace.getSpanRecorder(), statusCode); - } - try { + this.httpStatusCodeRecorder.record(trace.getSpanRecorder(), statusCode); final SpanEventRecorder recorder = trace.currentSpanEventRecorder(); if (trace.canSampled()) { recorder.recordException(throwable); diff --git a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListenerBuilder.java b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListenerBuilder.java index f22e74726bb0..7a56a2e4b2aa 100644 --- a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListenerBuilder.java +++ b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/request/ServletRequestListenerBuilder.java @@ -54,7 +54,6 @@ public class ServletRequestListenerBuilder { private List recordRequestHeaders; private List recordRequestCookies; - private boolean recordStatusCode = true; public ServletRequestListenerBuilder(final ServiceType serviceType, final TraceContext traceContext, @@ -97,10 +96,6 @@ public void setServerCookieRecorder(List recordRequestCookies) { this.recordRequestCookies = recordRequestCookies; } - public void setRecordStatusCode(boolean recordStatusCode) { - this.recordStatusCode = recordStatusCode; - } - private Filter newExcludeUrlFilter(Filter excludeUrlFilter) { if (excludeUrlFilter == null) { return new SkipFilter<>(); @@ -141,7 +136,7 @@ public ServletRequestListener build() { return new ServletRequestListener<>(serviceType, traceContext, requestAdaptor, requestTraceReader, - excludeUrlFilter, parameterRecorder, proxyRequestRecorder, serverRequestRecorder, httpStatusCodeRecorder, recordStatusCode); + excludeUrlFilter, parameterRecorder, proxyRequestRecorder, serverRequestRecorder, httpStatusCodeRecorder); } diff --git a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListener.java b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListener.java index 865a8226e64f..77ce60245db0 100644 --- a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListener.java +++ b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListener.java @@ -22,7 +22,6 @@ import com.navercorp.pinpoint.bootstrap.context.TraceContext; import com.navercorp.pinpoint.bootstrap.logging.PLogger; import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; -import com.navercorp.pinpoint.bootstrap.plugin.http.HttpStatusCodeRecorder; import com.navercorp.pinpoint.common.trace.ServiceType; import java.util.Objects; @@ -37,14 +36,11 @@ public class ServletResponseListener { private final TraceContext traceContext; private final ServerResponseHeaderRecorder serverResponseHeaderRecorder; - private final HttpStatusCodeRecorder httpStatusCodeRecorder; public ServletResponseListener(final TraceContext traceContext, - final ServerResponseHeaderRecorder serverResponseHeaderRecorder, - final HttpStatusCodeRecorder httpStatusCodeRecorder) { + final ServerResponseHeaderRecorder serverResponseHeaderRecorder) { this.traceContext = Objects.requireNonNull(traceContext, "traceContext"); this.serverResponseHeaderRecorder = Objects.requireNonNull(serverResponseHeaderRecorder, "serverResponseHeaderRecorder"); - this.httpStatusCodeRecorder = Objects.requireNonNull(httpStatusCodeRecorder, "statusCodeRecorder"); } @@ -72,9 +68,8 @@ public void destroyed(RESP response, final Throwable throwable, final int status return; } - final SpanRecorder spanRecorder = trace.getSpanRecorder(); - this.httpStatusCodeRecorder.record(spanRecorder, statusCode); if (trace.canSampled()) { + final SpanRecorder spanRecorder = trace.getSpanRecorder(); this.serverResponseHeaderRecorder.recordHeader(spanRecorder, response); } } diff --git a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListenerBuilder.java b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListenerBuilder.java index 03f023dee8cd..16c8379bd47b 100644 --- a/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListenerBuilder.java +++ b/bootstraps/bootstrap-core/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/response/ServletResponseListenerBuilder.java @@ -16,13 +16,10 @@ package com.navercorp.pinpoint.bootstrap.plugin.response; -import com.navercorp.pinpoint.bootstrap.config.HttpStatusCodeErrors; import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; import com.navercorp.pinpoint.bootstrap.context.TraceContext; -import com.navercorp.pinpoint.bootstrap.plugin.http.HttpStatusCodeRecorder; import com.navercorp.pinpoint.common.util.CollectionUtils; -import java.util.Collections; import java.util.List; import java.util.Objects; @@ -35,8 +32,6 @@ public class ServletResponseListenerBuilder { private List recordResponseHeaders; - private HttpStatusCodeErrors httpStatusCodeErrors; - public ServletResponseListenerBuilder(final TraceContext traceContext, final ResponseAdaptor responseAdaptor) { this.traceContext = Objects.requireNonNull(traceContext, "traceContext"); @@ -44,27 +39,11 @@ public ServletResponseListenerBuilder(final TraceContext traceContext, final ProfilerConfig profilerConfig = traceContext.getProfilerConfig(); final List recordResponseHeaders = profilerConfig.readList(ServerResponseHeaderRecorder.CONFIG_KEY_RECORD_RESP_HEADERS); - setRecordResponseHeaders(recordResponseHeaders); - setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); - } - - public void setRecordResponseHeaders(List recordResponseHeaders) { this.recordResponseHeaders = recordResponseHeaders; } - public void setHttpStatusCodeRecorder(final HttpStatusCodeErrors httpStatusCodeErrors) { - this.httpStatusCodeErrors = httpStatusCodeErrors; - } - public ServletResponseListener build() { - HttpStatusCodeRecorder httpStatusCodeRecorder; - if (httpStatusCodeErrors == null) { - HttpStatusCodeErrors httpStatusCodeErrors = new HttpStatusCodeErrors(Collections.emptyList()); - httpStatusCodeRecorder = new HttpStatusCodeRecorder(httpStatusCodeErrors); - } else { - httpStatusCodeRecorder = new HttpStatusCodeRecorder(httpStatusCodeErrors); - } - return new ServletResponseListener<>(traceContext, newServerResponseHeaderRecorder(), httpStatusCodeRecorder); + return new ServletResponseListener<>(traceContext, newServerResponseHeaderRecorder()); } private ServerResponseHeaderRecorder newServerResponseHeaderRecorder() { @@ -73,5 +52,4 @@ private ServerResponseHeaderRecorder newServerResponseHeaderRecorder() { } return new DefaultServerResponseHeaderRecorder<>(responseAdaptor, recordResponseHeaders); } - -} +} \ No newline at end of file diff --git a/bootstraps/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorderTest.java b/bootstraps/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorderTest.java index e47dd3c942e2..20c63b3af15c 100644 --- a/bootstraps/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorderTest.java +++ b/bootstraps/bootstrap-core/src/test/java/com/navercorp/pinpoint/bootstrap/plugin/http/HttpStatusCodeRecorderTest.java @@ -18,6 +18,7 @@ import com.navercorp.pinpoint.bootstrap.config.HttpStatusCodeErrors; import com.navercorp.pinpoint.bootstrap.context.SpanRecorder; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -46,4 +47,11 @@ public void record() throws Exception { recorder.record(spanRecorder, -1); recorder.record(spanRecorder, 999); } + + @Test + public void errorsIsNull() throws Exception { + Assertions.assertThrows(NullPointerException.class, () -> { + HttpStatusCodeRecorder recorder = new HttpStatusCodeRecorder(null); + }); + } } \ No newline at end of file diff --git a/plugins/jboss/src/main/java/com/navercorp/pinpoint/plugin/jboss/interceptor/StandardHostValveInvokeInterceptor.java b/plugins/jboss/src/main/java/com/navercorp/pinpoint/plugin/jboss/interceptor/StandardHostValveInvokeInterceptor.java index 7ce3c2f58434..24b16936bc51 100644 --- a/plugins/jboss/src/main/java/com/navercorp/pinpoint/plugin/jboss/interceptor/StandardHostValveInvokeInterceptor.java +++ b/plugins/jboss/src/main/java/com/navercorp/pinpoint/plugin/jboss/interceptor/StandardHostValveInvokeInterceptor.java @@ -88,7 +88,6 @@ public StandardHostValveInvokeInterceptor(final TraceContext traceContext, final reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build(); diff --git a/plugins/jetty/src/main/java/com/navercorp/pinpoint/plugin/jetty/interceptor/AbstractServerHandleInterceptor.java b/plugins/jetty/src/main/java/com/navercorp/pinpoint/plugin/jetty/interceptor/AbstractServerHandleInterceptor.java index 5e66d10fea7b..953759582d63 100644 --- a/plugins/jetty/src/main/java/com/navercorp/pinpoint/plugin/jetty/interceptor/AbstractServerHandleInterceptor.java +++ b/plugins/jetty/src/main/java/com/navercorp/pinpoint/plugin/jetty/interceptor/AbstractServerHandleInterceptor.java @@ -72,7 +72,6 @@ public AbstractServerHandleInterceptor(TraceContext traceContext, MethodDescript reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build(); diff --git a/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpServerHandleInterceptor.java b/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpServerHandleInterceptor.java index 76d939d6e9d7..1a7d43dfc843 100644 --- a/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpServerHandleInterceptor.java +++ b/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpServerHandleInterceptor.java @@ -79,7 +79,6 @@ public HttpServerHandleInterceptor(TraceContext traceContext, reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build(); this.servletResponseListener = new ServletResponseListenerBuilder<>(traceContext, new HttpResponseAdaptor()).build(); diff --git a/plugins/resin/src/main/java/com/navercorp/pinpoint/plugin/resin/interceptor/ServletInvocationServiceInterceptor.java b/plugins/resin/src/main/java/com/navercorp/pinpoint/plugin/resin/interceptor/ServletInvocationServiceInterceptor.java index fe0c3d43c96c..2fd42233679e 100644 --- a/plugins/resin/src/main/java/com/navercorp/pinpoint/plugin/resin/interceptor/ServletInvocationServiceInterceptor.java +++ b/plugins/resin/src/main/java/com/navercorp/pinpoint/plugin/resin/interceptor/ServletInvocationServiceInterceptor.java @@ -74,7 +74,6 @@ public ServletInvocationServiceInterceptor(TraceContext traceContext, MethodDesc reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build(); this.servletResponseListener = new ServletResponseListenerBuilder<>(traceContext, new HttpServletResponseAdaptor()).build(); diff --git a/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/jakarta/interceptor/StandardHostValveInvokeInterceptor.java b/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/jakarta/interceptor/StandardHostValveInvokeInterceptor.java index 55ef7a26b36e..b1067c95a605 100644 --- a/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/jakarta/interceptor/StandardHostValveInvokeInterceptor.java +++ b/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/jakarta/interceptor/StandardHostValveInvokeInterceptor.java @@ -79,7 +79,6 @@ public StandardHostValveInvokeInterceptor(TraceContext traceContext, MethodDescr reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build(); diff --git a/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/javax/interceptor/StandardHostValveInvokeInterceptor.java b/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/javax/interceptor/StandardHostValveInvokeInterceptor.java index 542bff4fe8e7..4cafbf795908 100644 --- a/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/javax/interceptor/StandardHostValveInvokeInterceptor.java +++ b/plugins/tomcat/src/main/java/com/navercorp/pinpoint/plugin/tomcat/javax/interceptor/StandardHostValveInvokeInterceptor.java @@ -80,7 +80,6 @@ public StandardHostValveInvokeInterceptor(TraceContext traceContext, MethodDescr reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build(); diff --git a/plugins/undertow/src/main/java/com/navercorp/pinpoint/plugin/undertow/interceptor/ConnectorsExecuteRootHandlerInterceptor.java b/plugins/undertow/src/main/java/com/navercorp/pinpoint/plugin/undertow/interceptor/ConnectorsExecuteRootHandlerInterceptor.java index 0b97519eb56a..b9240659ea46 100644 --- a/plugins/undertow/src/main/java/com/navercorp/pinpoint/plugin/undertow/interceptor/ConnectorsExecuteRootHandlerInterceptor.java +++ b/plugins/undertow/src/main/java/com/navercorp/pinpoint/plugin/undertow/interceptor/ConnectorsExecuteRootHandlerInterceptor.java @@ -74,7 +74,6 @@ public ConnectorsExecuteRootHandlerInterceptor(TraceContext traceContext, Method reqBuilder.setHttpStatusCodeRecorder(profilerConfig.getHttpStatusCodeErrors()); reqBuilder.setServerHeaderRecorder(profilerConfig.readList(ServerHeaderRecorder.CONFIG_KEY_RECORD_REQ_HEADERS)); reqBuilder.setServerCookieRecorder(profilerConfig.readList(ServerCookieRecorder.CONFIG_KEY_RECORD_REQ_COOKIES)); - reqBuilder.setRecordStatusCode(false); this.servletRequestListener = reqBuilder.build();