You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/27 21:27:42 UTC

[I] typed actor 日志缺少 sourceThread MDC 值 [pekko]

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: notifications-unsubscribe@pekko.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] typed actor 日志缺少 sourceThread MDC 值 [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on issue #3214:
URL: https://github.com/apache/pekko/issues/3214#issuecomment-4822168713

   Closing to recreate in English with independent verification.


-- 
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: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [I] typed actor 日志缺少 sourceThread MDC 值 [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin closed issue #3214: typed actor 日志缺少 sourceThread MDC 值
URL: https://github.com/apache/pekko/issues/3214


-- 
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: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org