He-Pin opened a new issue, #3214:
URL: https://github.com/apache/pekko/issues/3214

   ### Motivation
   
   Typed actor 的 MDC(Mapped Diagnostic Context)不包含 `sourceThread` 信息,而 classic 
actor 的 Slf4jLogger 会设置线程名。这导致 typed actor 的日志无法关联到执行线程,影响问题排查。
   
   ### 当前代码行为
   
   `ActorMdc.scala` 中 `setMdc` 方法只设置了以下 MDC key:
   - `pekkoSource`(actor path)
   - `sourceActorSystem`
   - `pekkoAddress`
   - `pekkoTags`
   
   缺少 `sourceThread`(或等效的线程名 MDC key)。
   
   对比 classic actor 的 `Slf4jLogger.scala:134`:
   ```scala
   MDC.put(mdcThreadAttributeName, logEvent.thread.getName)
   ```
   
   ### 预期行为
   
   typed actor 的 MDC 应包含 `sourceThread`(或 `pekkoThread`),值为当前执行线程的名称,与 classic 
actor 保持一致。
   
   ### 代码证据
   
   - 
`actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ActorMdc.scala:24-38`
 — `setMdc` 方法,仅设置 4 个 MDC key
   - `slf4j/src/main/scala/org/apache/pekko/event/slf4j/Slf4jLogger.scala:134` 
— classic actor 设置 `sourceThread` MDC
   
   ### 复现方式
   
   配置 MDC 日志,从 typed actor 发送消息,检查日志输出中是否有 `sourceThread` key。
   
   ### 影响范围
   
   - 模块:`pekko-actor-typed`
   - 影响所有使用 MDC 进行日志关联的 typed actor 用户
   - 在多线程环境中排查问题时缺少关键上下文信息


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to