wu-sheng commented on a change in pull request #5348:
URL: https://github.com/apache/skywalking/pull/5348#discussion_r473081884
##########
File path:
apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/mvc/commons/interceptor/AbstractMethodInterceptor.java
##########
@@ -208,4 +222,31 @@ private void collectHttpParam(HttpServletRequest request,
AbstractSpan span) {
Tags.HTTP.PARAMS.set(span, tagValue);
}
}
+
+ private boolean shouldCollectHeader() {
+ List<String> includeHeaders =
SpringMVCPluginConfig.Plugin.Http.INCLUDE_HTTP_HEADERS;
+ return includeHeaders != null && includeHeaders.size() > 0 ;
+ }
+
+ private void collectHttpHeaders(HttpServletRequest request, AbstractSpan
span) {
+ final Enumeration<String> headerNames = request.getHeaderNames();
+ if (headerNames == null) {
+ return;
+ }
+ final List<String> headersList = new LinkedList<>();
+ Collections.list(headerNames).stream().forEach(headerName -> {
+ Enumeration<String> headerValues = request.getHeaders(headerName);
+ String headerValue = Collections.list(headerValues).toString();
+ if (shouldCollectHeader() &&
SpringMVCPluginConfig.Plugin.Http.INCLUDE_HTTP_HEADERS.contains(headerName.toLowerCase()))
{
Review comment:
`SpringMVCPluginConfig.Plugin.Http.INCLUDE_HTTP_HEADERS not empty`
should be at the first line of the method, to provide `return` fast.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]