short background, in application we using doctrine transport for failed queues, so if message failed (all retries failed) messenger storing it to failed messages table and it's waiting for further actions. And I need somehow listen when message is sent to that table and update prometheus gauge and send alert.
I tried to do it in a same way I sending other messenger related metrics (with event subscriber, I found it much flexible than middlewares), so basically by listen to one of the https://symfony.com/doc/current/messenger.html#messenger-events, but I found it's not possible to catch a moment when messenger sending it to failure transport, messenger has SendMessageToTransportsEvent but it does not provide a transport name, so I can't understand if it's a failed or not...
Also I found messener has SentToFailureTransportStamp stamp, but for some reason that stamp is not present in the envlope when message failed and will be send to failed queue, but depends on class description Stamp applied when a message is sent to the failure transport. it should...
Only idea I have is to make a collector which will query failed messages table periodically and send amount of records to prometheus, but what if I'll change transport to something else???? It's mean I'll need to change a collector all the time...
Is there a way to catch a moment when messenger sending message to failed queue??? Thank you in advice!!!