alibaba / sentinel-golang

Sentinel Go enables reliability and resiliency for Go microservices
https://sentinelguard.io/
Apache License 2.0
2.77k stars 437 forks source link

[Feature] Carry params by key-value in sentinel.Entry | 热点参数埋点支持以 key-value 的方式传入参数 #490

Open sczyh30 opened 2 years ago

sczyh30 commented 2 years ago

Issue Description

Type: feature request

Describe what feature you want

Support carrying params by key-value in sentinel.Entry(options...). An example:

sentinel.Entry(WithArg("key1", "value1"), WithArg("key2", "value2"));

热点参数埋点支持以 key-value 的方式传入参数,这样开发者可以无需像之前传入 args 一样关心参数顺序,从而更方便的配置热点规则(按照 key 来匹配即可,不需按参数匹配)。

热点规则的设计,以及 Entry API 的设计需要做相应的调整。

Additional context

Add any other context or screenshots about the feature request here.

binbin0325 commented 1 year ago

目前已支持,如下:

        e, b := sentinel.Entry("abc",
            sentinel.WithArgs(false, uint32(9),
                sentinel.WithAttachments(map[interface{}]interface{}{
                    testKey: rand.Uint64() % 10,
                }),
            ))
sczyh30 commented 1 year ago

Args, Attachments 的用途,咱们可以在文档里面明确下哈,方便大家进行扩展使用。cc @LearningGp

cc @ansiz 可以看下对扩展性的需求

ansiz commented 1 year ago

@sczyh30 我看title上看跟热点限流有关系?但是好像没看到热点限流那边的改动?这个改动有完整的PR链接吗?

我们之前其实已经做过类似的实现,在热点限流支持指定key,再从上下文里提取参数