alibaba / alibaba/Sentinel

在非web环境下自定义了limitApp来源,怎么设置origin的值?

Open
#2,824 1 comment 0 reactions 0 assignees View on GitHub
kind/question
Dominant language
Java
Stars
23.1k
Forks
8.1k
PR merge metrics
No merged PRs in 30d

Description

使用 `@SentinelResource` 注解进行限流、熔断,同时规则里面设置了 `limitApp` 属性,怎么能更改 `origin` 的值,在com.alibaba.csp.sentinel.CtSph#entryWithPriority(com.alibaba.csp.sentinel.slotchain.ResourceWrapper, int, boolean, java.lang.Object...)方法里面通过InternalContextUtil.internalEnter(Constants.CONTEXT_DEFAULT_NAME)设置Context对象的属性,但是 `origin` 的值为空字符串,限流的逻辑在com.alibaba.csp.sentinel.slots.block.flow.FlowRuleChecker#selectNodeByRequesterAndStrategy方法里面比较 `limitApp` 和 `origin` 的值,两者不一致,导致限流失败。

Contributor guide

Open the contributing guide

Research direction

Start with CtSph#entryWithPriority and InternalContextUtil.internalEnter to trace how the Context is created in a non-web environment. Then inspect FlowRuleChecker#selectNodeByRequesterAndStrategy and the comparison between limitApp and origin; done means callers have a documented, working way to set origin so the configured limitApp is matched.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.