Skip to content

Fix messenger middleware merge#63

Merged
jstojiljkovic merged 3 commits into
tracewayapp:masterfrom
d-mitrofanov-v:fix/messenger-middleware-merge
Jul 12, 2026
Merged

Fix messenger middleware merge#63
jstojiljkovic merged 3 commits into
tracewayapp:masterfrom
d-mitrofanov-v:fix/messenger-middleware-merge

Conversation

@d-mitrofanov-v

Copy link
Copy Markdown
Contributor

Hi, everyone! I noticed, that when an application adds its own middleware to a Symfony Messenger bus, OpenTelemetry middleware from the bundle is no longer registered. For example, this configuration removes OpenTelemetry middleware from the resulting middleware stack:

framework:
    messenger:
        buses:
            messenger.bus.default:
                middleware:
                    - App\Messenger\Middleware\CustomMiddleware

The problem is that Symfony does not deep merge the middleware option. Right now the bundle prepends its middleware through FrameworkBundle configuration, but application configuration replaces the prepended middleware list.

I propose moving OpenTelemetry middleware registration to a compiler pass. The compiler pass will update the middleware stack after FrameworkBundle has normalized Messenger configuration, but before Symfony builds the buses.

With this change application middleware will be preserved, tracing and metrics middleware will be added before send_message and handle_message, and the configured default_bus will still be respected. Manually configured OpenTelemetry middleware will also not be added twice.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@jstojiljkovic
jstojiljkovic merged commit dacae4e into tracewayapp:master Jul 12, 2026
9 checks passed
jstojiljkovic added a commit that referenced this pull request Jul 14, 2026
* fix: span-loss, metrics correctness, semconv alignment

* fix: reconcile with messenger middleware compiler pass (#63)

* chore: return cache passing tag

* docs: updated changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants