spring-cloud-gateway
spring-cloud-gateway copied to clipboard
GatewayMetricsFilter should have Ordered.HIGHEST_PRECEDENCE
Describe the bug
GatewayMetricsFilter currently runs with order NettyWriteResponseFilter.WRITE_RESPONSE_FILTER_ORDER + 1
I kind of understand the reasoning behind this, since NettyWriteResponseFilter flushes the response to client that is the reason we want to stop timer before we flush the response, but this has following caveats:
- We are missing on the time taken by pre-filters that run before
GatewayMetricsFilteri.e. filter with higher precedence thanGatewayMetricsFilter - On doing this we might start adding extra time to duration metrics as this is start including the time taken by post filters that execute after
GatewayMetricsFilter, but considering the face that likelihood of doing post processing after flushing response to client is pretty low, the duration overhead will be very minimal.
Sample