Activate metrics for route filters
Is your feature request related to a problem? Please describe.
There is no way to measure the time and overhead of a specific filter and the combinations of several filters in a route.
The upstream service call and looking up the correct route will be included in the latency, so measuring response time of a request to SCG doesn't provide a way to know time/overhead of applying filters.
Describe the solution you'd like
Having the following example
- id: remove_response_header_test
uri: http://httpbin.org
predicates:
- Host=**.removereresponseheader.org
- Path=/headers
filters:
- RemoveResponseHeader=X-Request-Foo
- AddResponseHeader=X-Request-Foo, Bar
- RemoveJsonAttributesResponseBody=id,color
I want to get the time spent in each filter for a request: time(RemoveResponseHeader), time(RemoveJsonAttributesResponseBody), and time(RemoveJsonAttributesResponseBody) will allow us to check if the filters are working fine together and if one of them is adding extra latency.
Describe alternatives you've considered
I implemented StartTimer and StopTimer filters which use Micrometer to register metrics between the defined boundaries.
filters:
- StartTimer=response-headers-metric
- RemoveResponseHeader=X-Request-Foo
- AddResponseHeader=X-Request-Foo, Bar
- StopTimer=response-headers-metric
- StartTimer=remove-json-metric
- RemoveJsonAttributesResponseBody=id,color
I will register via micrometer the metrics for response-headers-metric and remove-json-metric.
Both are tagged by the route_id and also the request URI, so you can get numbers from different situations.
Limitations:
- One big limitation is that it doesn't work with
Orderedfilters. For example,LocalResponseCacheis aOrderedfilter, having that you cannot define a boundary to contain it. - The developer needs to change the route configuration in order to measure the time
Additional context
- If SCG OSS would have a built-in feature to register metrics for filters, we hadn't some of the limitations above.
- Also, maybe we could activate other metrics like the time spent on Predicates
Dear team ,we need exactly same functionality on reactive gateway, any news for this feature to go in to the plan ?