fix(java): 部署级字段从全局配置读取,不再依赖线程本地 MDC - #14
Merged
wyhhai merged 1 commit intoSep 20, 2026
Merged
Conversation
请求线程打日志时 service/env/instance 曾因 init() 只写启动线程 MDC 而整条缺失; ObsJsonProvider 改为直接读 ObsLogging 全局静态访问器(未 init 回退契约默认), community 保持 MDC 请求级覆盖 > 部署默认语义。补新线程回归测试。
Welcome To opensourceways CommunityHey @wyhhai , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature Passwyhhai, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Linking Issue Notice@wyhhai , the pull request must be linked to at least one issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
缺陷
Java SDK 输出的结构化日志中,契约要求的固定标签 service / env / instance 整条缺失(om-webserver 接入实测)。
实际输出:
{"time":"...","level":"info","msg":"...","community":"unknown","request_id":"...","logger":"LogUtil.java:107"}
根因
ObsLogging.init() 把部署级字段写入 SLF4J MDC(线程本地存储):
部署级字段本质是全局静态配置(来源 OBS_* 环境变量),用线程本地 MDC 承载属于错误建模。
修复
deploymentCommunity() 改为公开;init() 不再写 MDC,未 init 时回退契约默认 Env.DEFAULT_VALUE
验证