Skip to content

Commit

Permalink
[enhancement]changing the order of http filters and aspects.
Browse files Browse the repository at this point in the history
The order of HttpLoggingFilter has been changed from HIGHEST_PRECEDENCE + 1 to -280.
The order of HttpMdcFilter has been changed from HIGHEST_PRECEDENCE to -300.
The order of HttpStatisticsFilter has been changed from 20 to -290.
The order of TimerStatisticsAspect has been changed from HIGHEST_PRECEDENCE to 20.
  • Loading branch information
ebrahimiar authored Jun 30, 2024
1 parent d73dc04 commit 5f30383
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ it as a maven dependency and enable the desired functionality.

### mdc filter
one of the common requirements of Http server is providing correct mdc parameters in order to trace request easily.
to reach this goal a filter name HttpMdcFilter is provided. this bean is defined by default as below:
to reach this goal a filter name HttpMdcFilter is provided.
The order of this filter is -300.
this bean is defined by default as below:
```
@Bean
@ConditionalOnMissingBean
Expand Down Expand Up @@ -268,8 +270,9 @@ your required comparison type can be specified in each securedParameter as below
securedParameters.add(new SecureParameter("pan", UserMaskType.PAN, ComparisonType.RIGHT_LIKE));
```

for logging data a bean of type HttpLoggingFilter is provided by default as below. this bean exlude actuator url pattern
for logging data a bean of type HttpLoggingFilter is provided by default as below. this bean excludes actuator url pattern
(/actuator/*) by default.
The order of this filter is -280.
```
@Bean
@ConditionalOnMissingBean
Expand Down Expand Up @@ -308,6 +311,7 @@ masking will be applied for :
### statistics filter
HttpStatisticsFilter is created for purpose of logging simple metrics about http requests.
The order of this filter is -290
this filter logs some metrics as below:
on request:
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
* @author AmirHossein ZamanZade
* @since 10/22/2022
*/
@Aspect
@Order(Ordered.HIGHEST_PRECEDENCE)
@Order(20)
public class TimerStatisticsAspect {

private final TimerStatisticsUtil timerStatisticsUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.util.ContentCachingResponseWrapper;

Expand All @@ -23,7 +22,7 @@
* @author M.khoshnevisan
* @since 4/21/2021
*/
@Order(Ordered.HIGHEST_PRECEDENCE + 1)
@Order(-280)
public class HttpLoggingFilter extends OncePerRequestFilterBase {

private static final Logger LOGGER = LoggerFactory.getLogger(HttpLoggingFilter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

import java.io.IOException;
Expand All @@ -18,7 +17,7 @@
* @author mina khoshnevisan
* @since 7/16/2022
*/
@Order(Ordered.HIGHEST_PRECEDENCE)
@Order(-300)
public class HttpMdcFilter extends OncePerRequestFilterBase {

private final MdcUtil mdcLogUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @author mina khoshnevisan
* @since 7/20/2022
*/
@Order(20)
@Order(-290)
public class HttpStatisticsFilter extends OncePerRequestFilterBase {
private static final Logger LOGGER = LoggerFactory.getLogger(HttpStatisticsFilter.class);
private static final AtomicLong activeRequestsCount = new AtomicLong(0);
Expand Down

0 comments on commit 5f30383

Please sign in to comment.