He-Pin opened a new issue, #3239:
URL: https://github.com/apache/pekko/issues/3239
### Description
The MDC (Mapped Diagnostic Context) setup for typed actors does not include
the `sourceThread` attribute, making it impossible to correlate log entries
with the dispatching thread.
### Affected code
`actor-typed/src/main/scala/org/apache/pekko/actor/typed/internal/ActorMdc.scala`
(lines 24-38):
The `setMdc` method sets only these MDC keys:
- `pekkoSource`
- `sourceActorSystem`
- `pekkoAddress`
- `pekkoTags` (conditional)
`sourceThread` is **not** included.
### Comparison with classic actors
The classic actor path **does** set `sourceThread` via `Slf4jLogger.withMdc`
(line 134):
```scala
MDC.put(mdcThreadAttributeName, logEvent.thread.getName)
```
The typed actor logging documentation (`typed/logging.md`) describes
`sourceThread` as if it were set, but the implementation never populates it for
typed actors.
### Expected behavior
Typed actor log entries should include `sourceThread` in MDC, consistent
with classic actors and the documentation.
### Suggested fix
Add `MDC.put("sourceThread", Thread.currentThread().getName)` to
`ActorMdc.setMdc`, alongside the existing MDC attributes.
--
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]