AI observability upgrade (#1587)

Co-authored-by: Kent Dong <ch3cho@qq.com>
This commit is contained in:
rinfx
2024-12-16 10:27:49 +08:00
committed by GitHub
parent 8544fa604d
commit ec39d56731
11 changed files with 194 additions and 236 deletions

View File

@@ -45,6 +45,8 @@ type HttpContext interface {
GetStringContext(key, defaultValue string) string
GetUserAttribute(key string) interface{}
SetUserAttribute(key string, value interface{})
SetUserAttributeMap(kvmap map[string]interface{})
GetUserAttributeMap() map[string]interface{}
// You can call this function to set custom log
WriteUserAttributeToLog() error
// You can call this function to set custom log with your specific key
@@ -403,6 +405,14 @@ func (ctx *CommonHttpCtx[PluginConfig]) GetUserAttribute(key string) interface{}
return ctx.userAttribute[key]
}
func (ctx *CommonHttpCtx[PluginConfig]) SetUserAttributeMap(kvmap map[string]interface{}) {
ctx.userAttribute = kvmap
}
func (ctx *CommonHttpCtx[PluginConfig]) GetUserAttributeMap() map[string]interface{} {
return ctx.userAttribute
}
func (ctx *CommonHttpCtx[PluginConfig]) WriteUserAttributeToLog() error {
return ctx.WriteUserAttributeToLogWithKey(CustomLogKey)
}