alibaba / spring-cloud-alibaba

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.
https://sca.aliyun.com
Apache License 2.0
28.02k stars 8.35k forks source link

spring-cloud-alibaba-sentinel add exclude #986

Open khiker007 opened 5 years ago

khiker007 commented 5 years ago

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。 We recommend using English. If you are non-native English speaker, you can use the translation software.

Which Component Sentinel

Is your feature request related to a problem? Please describe.

Actor health check endpoints and sentinel are added to the web project, and / actuator /* of sentinel health check is also monitored in sentinel. Dubbo methods such as com. alibaba. cloud. dubbo. service. DubboMetadata Service: getExportedURLs are also monitored in projects using dubbo.

web 项目中增加了actuator健康检查端点和sentinel,sentinel中健康检查的/actuator/*也在sentinel的监控中,在使用dubbo的项目中com.alibaba.cloud.dubbo.service.DubboMetadataService:getExportedURLs等dubbo方法也在监控住

Describe the solution you'd like

Similar to urlPatterns, excludePatterns options can be added, and resources not included in monitoring can be added using regularization

类似urlPatterns,可以增加excludePatterns选项,可以使用正则添加不纳入监控的资源

fangjian0423 commented 5 years ago

Related https://github.com/alibaba/Sentinel/issues/1099.

sczyh30 commented 5 years ago

I think we could leverage the UrlCleaner to achieve this. Since 1.6.3, when we unify the URL as the empty string, the URL resource will not be included in Sentinel Web filter.

A simple example:

WebCallbackManager.setUrlCleaner(new UrlCleaner() {
    @Override
    public String clean(String originUrl) {
        if (originUrl == null || originUrl.isEmpty()) {
            return "";
        }
        // 不希望统计 *.ico 的资源文件,可以将其转换为 empty string (since 1.6.3)
        if (originUrl.endsWith(".ico")) {
            return "";
        }
        return originUrl;
    }
});