alibaba / alibaba/Sentinel

配置网关限流时,Sentinel管理台的流控规则不显示网关流控页面

Open
#2,271 7 comments 0 reactions 0 assignees View on GitHub
area/dashboard area/gateway-flow-control
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

## Issue Description

Type: Bug

### Describe what happened (or what feature you want)
不配置csp.sentinel.app.type=1这个参数,则sentinal-dashboard中的gateway流控规则不能显示网关流控规则页面。

### Describe what you expected to happen
正常应该在不配置csp.sentinel.app.type的情况下是可以展示网关流控页面的

### How to reproduce it (as minimally and precisely as possible)

1. 使用sentinel-1.8.2版本
2. gateway服务中依赖了spring-cloud-alibaba-sentinel-gateway、spring-cloud-starter-alibaba-sentinel、sentinel-datasource-nacos,做了sentinel规则持久化到nacos,用的示例代码
3. 在启动时不使用-Dcsp.sentinel.app.type=1

### Tell us your environment
JDK:1.8
OS:Windows10
IDEA:2020.3

### Anything else we need to know?
HeartbeatMessage类是通过SPI实例化SimpleHttpHeartbeatSender时实例化的,里边通过SentinelConfig.getAppType()得到app_type,最终是通过System.getProperty()去拿值,如果为空,则取默认值0,之后才会在Spring容器初始化时调用SentinelSCGAutoConfiguration的 initAppType()方法,设置System.setProperty("csp.sentinel.app.type", "11");但是此时HeartbeatMessage的app_type已经不可修改,发送心跳参数heartBeat.generateCurrentMessage()里边也没有对HeartbeatMessage类的app_type属性重新赋值,也就是说app_type会一直为0,导致dashboard没有网关流控页面。
问题原因:SentinelSCGAutoConfiguration中对csp.sentinel.app.type的赋值没有真正被用到。

Contributor guide

Open the contributing guide

Research direction

Start with HeartbeatMessage and SimpleHttpHeartbeatSender, then inspect SentinelSCGAutoConfiguration.initAppType() and the heartbeat message generation path. Reproduce with Sentinel 1.8.2 without csp.sentinel.app.type and the gateway sample dependencies. Done means the dashboard displays the gateway flow-control rules page without that system property.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.