File tree Expand file tree Collapse file tree
src/main/java/nl/dtls/fairdatapoint/api/filter Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import org .springframework .web .filter .OncePerRequestFilter ;
1111
1212import java .io .IOException ;
13+ import java .util .Optional ;
1314
1415@ Slf4j
1516@ Component
@@ -37,22 +38,17 @@ public void doFilterInternal(
3738 final HttpServletResponse response ,
3839 final FilterChain filterChain
3940 ) throws IOException , ServletException {
41+ log .debug ("Actuator counting request for {}" , request .getRequestURL ());
42+ // From [servlet spec]: requestURI = contextPath + servletPath + pathInfo
43+ // [servlet spec]: https://jakarta.ee/specifications/servlet/6.1/jakarta-servlet-spec-6.1#request-path-elements
4044 final String uri = request .getRequestURI ();
4145 final String method = request .getMethod ();
42- String query = request .getQueryString ();
43- if (query == null ) {
44- query = "" ;
45- }
46- String path = request .getServletPath ();
47- if (path == null ) {
48- path = "" ;
49- }
50- log .debug ("Actuator counting request for {}" , uri );
46+ final Optional <String > query = Optional .ofNullable (request .getQueryString ());
5147 meterRegistry .counter (
5248 "custom" ,
5349 "method" , method ,
54- "path " , path ,
55- "query " , query
50+ "query " , query . orElseGet (() -> "" ) ,
51+ "uri " , uri
5652 ).increment ();
5753 filterChain .doFilter (request , response );
5854 }
You can’t perform that action at this time.
0 commit comments