Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add plugin start log in sdk #1831

Merged
merged 3 commits into from
Mar 3, 2025
Merged

Conversation

rinfx
Copy link
Collaborator

@rinfx rinfx commented Feb 27, 2025

插件增加一个内置字段_plugin_id_,通过打印日志标明插件启动是否成功

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.41%. Comparing base (ef31e09) to head (300c8d1).
Report is 321 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1831      +/-   ##
==========================================
+ Coverage   35.91%   43.41%   +7.50%     
==========================================
  Files          69       76       +7     
  Lines       11576    12278     +702     
==========================================
+ Hits         4157     5331    +1174     
+ Misses       7104     6617     -487     
- Partials      315      330      +15     

see 71 files with indirect coverage changes

@rinfx
Copy link
Collaborator Author

rinfx commented Feb 27, 2025

_plugin_id_应用场景为区分多个网关的插件日志,插件配置中需额外指定_plugin_id_字段,如不指定,默认为nil,配置示例:

_plugin_id_: sdqwdacscfqw21
_rules_: ...
...

调整后插件日志格式示例如下:

// 启动失败日志
[ai-statistics] [sdqwdacscfqw21] [nil] plugin start failed
// 启动成功日志
[ai-statistics] [sdqwdacscfqw21] [nil] plugin start successfully
// 业务请求日志
[ai-statistics] [sdqwdacscfqw21] [1ce56bf7-891c-9d8f-90a2-d714b89bdfb3] get usage information failed, skip metric record

进一步,在日志中可通过正则提取 plugin_id 以及 request_id 构建索引以供查询

Copy link
Collaborator

@johnlanni johnlanni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johnlanni johnlanni merged commit 988e2c1 into alibaba:main Mar 3, 2025
12 checks passed
return types.OnPluginStartStatusFailed
}
}
ctx.vm.log.Error("plugin start successfully")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该是 info 级别的日志哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants