11# Messenger Logging Bundle
22
3- Symfony bundle for Messenger-Lifecycle-Logging , suitable for monitoring.
3+ Symfony bundle for Messenger lifecycle logging , suitable for monitoring.
44
55## Installation
66
@@ -26,23 +26,118 @@ c10k_messenger_logging:
2626 failed : error
2727 retried : warning
2828 skipped : warning
29+ stamp_normalizers : { }
2930` ` `
3031
31- Alle PSR-3-Levels sind erlaubt. Wenn Failure-Logs in einer retry-lastigen
32- Umgebung zu laut sind, kannst du ` failed: info` setzen .
32+ All PSR-3 log levels are supported. If failure logs are too noisy in a
33+ retry-heavy environment, you can set ` failed: info`.
3334
34- Wenn `log_channel` gesetzt ist, werden nur die von diesem Bundle erzeugten
35- Logs auf diesen Monolog-Channel gelegt. Andere Projekt-Logs bleiben davon
36- unberührt, solange sie nicht separat auf denselben Channel konfiguriert werden.
37- Ohne `log_channel` bleibt das bisherige Default-Logger-Verhalten unverändert .
35+ If `log_channel` is set, only the logs emitted by this bundle are sent to that
36+ Monolog channel. Other project logs remain unaffected unless they are
37+ explicitly configured to use the same channel. Without `log_channel`, the
38+ default logger behavior remains unchanged .
3839
39- Das Bundle hängt sich an Messenger-Events und sorgt dafür, dass eine Message
40- beim Queueing eine UUIDv7 erhält. Dieselbe UUID taucht dann in den Logs für
41- Queueing, Consume, Success, Failure und Retry wieder auf, zusammen mit der
42- Message-Klasse und dem vollständigen Stamp-Kontext .
40+ The bundle subscribes to Messenger events and ensures that each message
41+ receives a UUIDv7 when it is queued. The same UUID then appears in the logs for
42+ queueing, receiving, success, failure, and retry, together with the message
43+ class and a normalized `stamps` array .
4344
44- Wenn die installierte Messenger-Version `WorkerMessageSkipEvent` unterstützt,
45- werden auch übersprungene Messages geloggt.
45+ Stamp normalization is explicit. The bundle ships dedicated normalizers for a
46+ safe subset of Messenger stamps such as `BusNameStamp`, `DelayStamp`,
47+ ` HandledStamp` , `RedeliveryStamp`, `RouterContextStamp`, `SentStamp`,
48+ ` TransportNamesStamp` , and `ValidationStamp`. Unknown stamps are still listed
49+ by class name, but their `context` remains empty unless a normalizer is
50+ registered for them. This avoids reflecting every public getter on every stamp,
51+ which can expose sensitive data or large payloads such as handler results.
52+
53+ Custom normalizers are discovered automatically when they implement
54+ ` C10k\M essengerLoggingBundle\L ogging\S tampNormalizerInterface` and are
55+ registered as autoconfigured services. The bundle tags them with
56+ ` c10k_messenger_logging.stamp_normalizer` and maps them by supported stamp
57+ class.
58+
59+ You can also wire an explicit `StampClass -> NormalizerClass` mapping via
60+ configuration, which is useful for overrides :
61+
62+ ` ` ` yaml
63+ c10k_messenger_logging:
64+ stamp_normalizers:
65+ App\M essenger\C ustomStamp: App\M essenger\L ogging\C ustomStampNormalizer
66+ ` ` `
67+
68+ If the installed Messenger version supports `WorkerMessageSkipEvent`, skipped
69+ messages are logged as well.
70+
71+ # # Example Lifecycle
72+
73+ The example below shows how a single message can appear in the logs when it is
74+ queued, fails once, is retried, and is eventually handled successfully. The
75+ same `uuid` is present in every log entry, which makes correlation
76+ straightforward.
77+
78+ <table>
79+ <thead>
80+ <tr>
81+ <th>event</th>
82+ <th>context</th>
83+ </tr>
84+ </thead>
85+ <tbody>
86+ <tr>
87+ <td><code>message queued</code></td>
88+ <td><pre>uuid : 018f0c0c-6f9e-7eec-bfc3-6f8d3426f5dc
89+ message_class : App\Message\SyncInvoice
90+ sender_names : ["async"]
91+ retry_count : 0</pre></td>
92+ </tr>
93+ <tr>
94+ <td><code>message received (attempt 1)</code></td>
95+ <td><pre>uuid : 018f0c0c-6f9e-7eec-bfc3-6f8d3426f5dc
96+ message_class : App\Message\SyncInvoice
97+ receiver_name : async
98+ received_transport_names : ["async"]
99+ retry_count : 0</pre></td>
100+ </tr>
101+ <tr>
102+ <td><code>message failed (will retry)</code></td>
103+ <td><pre>uuid : 018f0c0c-6f9e-7eec-bfc3-6f8d3426f5dc
104+ message_class : App\Message\SyncInvoice
105+ receiver_name : async
106+ received_transport_names : ["async"]
107+ retry_count : 0
108+ will_retry : true
109+ exception_class : RuntimeException
110+ exception_message : Temporary upstream timeout</pre></td>
111+ </tr>
112+ <tr>
113+ <td><code>message scheduled for retry</code></td>
114+ <td><pre>uuid : 018f0c0c-6f9e-7eec-bfc3-6f8d3426f5dc
115+ message_class : App\Message\SyncInvoice
116+ receiver_name : async
117+ retry_count : 1</pre></td>
118+ </tr>
119+ <tr>
120+ <td><code>message received (attempt 2)</code></td>
121+ <td><pre>uuid : 018f0c0c-6f9e-7eec-bfc3-6f8d3426f5dc
122+ message_class : App\Message\SyncInvoice
123+ receiver_name : async
124+ received_transport_names : ["async"]
125+ retry_count : 1</pre></td>
126+ </tr>
127+ <tr>
128+ <td><code>message handled</code></td>
129+ <td><pre>uuid : 018f0c0c-6f9e-7eec-bfc3-6f8d3426f5dc
130+ message_class : App\Message\SyncInvoice
131+ receiver_name : async
132+ received_transport_names : ["async"]
133+ retry_count : 1</pre></td>
134+ </tr>
135+ </tbody>
136+ </table>
137+
138+ Each entry also contains the normalized `stamps` array, plus fields such as
139+ ` transport_message_id` , `from_failed_transport`, and
140+ ` failed_transport_original_receiver_name` when those details are available.
46141
47142# # Local development
48143
0 commit comments