spring-cloud / spring-cloud/spring-cloud-gateway

GatewayMetricsFilter should have Ordered.HIGHEST_PRECEDENCE

Open
#3,417 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

waiting-for-triage
Dominant language
Java
Stars
4.9k
Forks
3.5k
Avg merge
20h 57m
Merged PRs (30d)
8

Description

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 GatewayMetricsFilter i.e. filter with higher precedence than GatewayMetricsFilter
  • 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
Screenshot 2024-05-31 at 3 44 16 PM

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate GatewayMetricsFilter and NettyWriteResponseFilter, then inspect their filter ordering and how the metrics timer is stopped relative to response flushing. Confirm that the intended behavior includes higher-precedence pre-filters while preserving the response-flush behavior, and validate the change with the relevant gateway tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.