-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can servlet filter(CommonFilter) support ParamFlow? #2014
Comments
是的,原因是 目前 可能原因是,对于http request请求,不同项目可能获取参数的方式不一样。比如: PS: 它可用于清洗或者过滤资源(比如将满足 /foo/:id 的 URL 都归到 /foo/* 资源下,比如通过返回""排除某个URL) |
我对这个问题的看法是:对于 SphU#entry 方法的调用是否可以用 protected 方法取代,在 AbstractSentinelInterceptor 中实现默认的方法,使其子类可以覆盖这个默认方法,在这个 protected 中传入 interceptor 的 pre 方法的入参,这样子类决定怎么处理参数和怎么调用 SphU#entry,我是准备在项目中重写 AbstractSentinelInterceptor 这个类。 |
这个建议是直接fork出springmvc的adapter进行自定义来实现(改为自己的package),或者使用注解方式针对某几个方法来启用热点相关的流控。 因为参数多样,且影响一定性能,这个可能较难作为通用需求(filter模式) |
我觉得这只需要支持常用的一两种就可以,比如支持get/post,就已经满足90%的场景了。 |
Issue Description
Type: feature request
Describe what happened (or what feature you want)
Can servlet filter support ParamFlow?
Servlet filter模式的限流(com.alibaba.csp.sentinel.adapter.servlet.CommonFilter)可以支持热点参数限流吗?
Describe what you expected to happen
ParamFlow is supported in servlet filter mode.
热点参数限流可以在servlet限流模式中被支持。
How to reproduce it (as minimally and precisely as possible)
使用springMVC定义一个GET方法
@GetMapping("param") public String testParam(Integer param) { LOGGER.info("Dubbo request succeed. param is [{}]", param); return "Dubbo request succeed."; }
如下所示,配置一条热点参数限流规则
[ { "resource": "/param", "limitApp": "default", "grade": 1, "paramIdx": 0, "count": 1, "controlBehavior": 0, "maxQueueingTimeMs": 0, "burstCount": 0, "durationInSec": 1, "paramFlowItemList": [ { "object": "1", "count": 2, "classType": "int" } ], "clusterMode": false } ]
发送’param‘的http请求
结果是热点参数限流规则没有生效。
初步分析,原因是CommonFilter这个类调用SphU#entry方法时,没有传入参数列表。
如果使用@SentinelResource来做资源定义,热点参数限流规则可以生效。
’
@SentinelResource(value = "/param")
public String testParam(Integer param) {
LOGGER.info("Dubbo request succeed. param is [{}]", param);
return "Dubbo request succeed.";
}
‘
Tell us your environment
mac,sentinel-1.8.0
Anything else we need to know?
No more.
The text was updated successfully, but these errors were encountered: