Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors Mocha’s messaging diagnostics from a single IBusDiagnosticObserver to a listener-based model (IMessagingDiagnosticEventListener / IMessagingDiagnosticEvents) that supports multiple registered listeners and aligns error-path signaling across dispatch/receive/consume.
Changes:
- Replace
IBusDiagnosticObserverwithIMessagingDiagnosticEventsand listener/aggregation infrastructure. - Update dispatch/consume instrumentation middlewares to emit error events on exceptions.
- Update tests and the OpenTelemetry example to use the new diagnostic listener registration APIs.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Mocha/test/Mocha.Tests/Middlewares/Receive/ReceiveInstrumentationMiddlewareTests.cs | Updates tests to use IMessagingDiagnosticEvents and renamed error callback expectations. |
| src/Mocha/test/Mocha.Tests/Middlewares/Dispatch/DispatchInstrumentationMiddlewareTests.cs | Updates tests to use IMessagingDiagnosticEvents. |
| src/Mocha/test/Mocha.Tests/Middlewares/Consume/ConsumerInstrumentationMiddlewareTests.cs | Updates tests to use IMessagingDiagnosticEvents. |
| src/Mocha/src/Mocha/Observability/NoOpBusDiagnosticObserver.cs | Removes old no-op observer implementation. |
| src/Mocha/src/Mocha/Observability/IBusDiagnosticObserver.cs | Removes old observer interface. |
| src/Mocha/src/Mocha/Observability/Configuration/InstrumentationBusExtensions.cs | Adds listener registration APIs (AddDiagnosticEventListener) and updates AddInstrumentation(). |
| src/Mocha/src/Mocha/Middlewares/Receive/ReceiveInstrumentationMiddleware.cs | Switches receive instrumentation to IMessagingDiagnosticEvents. |
| src/Mocha/src/Mocha/Middlewares/Dispatch/DispatchInstrumentationMiddleware.cs | Switches to IMessagingDiagnosticEvents and adds dispatch error callback on exception. |
| src/Mocha/src/Mocha/Middlewares/Consume/ConsumerInstrumentationMiddleware.cs | Switches to IMessagingDiagnosticEvents and adds consume error callback on exception. |
| src/Mocha/src/Mocha/Instrumentation/NoopMessagingDiagnosticEvents.cs | Introduces no-op diagnostics implementation for the new model. |
| src/Mocha/src/Mocha/Instrumentation/MessagingDiagnosticEventListener.cs | Adds a base class with no-op defaults and a shared empty scope. |
| src/Mocha/src/Mocha/Instrumentation/IMessagingDiagnosticEvents.cs | Introduces the new diagnostics events interface used by middlewares. |
| src/Mocha/src/Mocha/Instrumentation/IMessagingDiagnosticEventListener.cs | Introduces the listener interface (multiple implementations supported). |
| src/Mocha/src/Mocha/Instrumentation/AggregateMessagingDiagnosticEvents.cs | Adds aggregation over multiple listeners, returning an aggregate scope. |
| src/Mocha/src/Mocha/Instrumentation/ActivityMessagingDiagnosticListener.cs | Replaces prior OpenTelemetry observer with an Activity-based listener implementation. |
| src/Mocha/src/Mocha/Builder/MessageBusBuilder.cs | Resolves listeners and selects no-op/single/aggregate diagnostics for runtime. |
| src/Mocha/src/Examples/Observability/OpenTelemetry/OpenTelemetryExample.cs | Updates example to register instrumentation + a custom listener via the new APIs. |
Comments suppressed due to low confidence (1)
src/Mocha/src/Mocha/Instrumentation/ActivityMessagingDiagnosticListener.cs:7
- This change replaces the previously
publicOpenTelemetry diagnostic observer type with aninternallistener (ActivityMessagingDiagnosticListener). IfOpenTelemetryDiagnosticObserverwas part of the public surface area, this is a breaking change for consumers who referenced it directly. Consider keeping a public, obsolete shim type (forwarding to the new listener model) or documenting the migration path in release notes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Mocha/src/Mocha/Observability/Configuration/InstrumentationBusExtensions.cs
Show resolved
Hide resolved
src/Mocha/src/Mocha/Observability/Configuration/InstrumentationBusExtensions.cs
Outdated
Show resolved
Hide resolved
src/Mocha/src/Mocha/Middlewares/Dispatch/DispatchInstrumentationMiddleware.cs
Show resolved
Hide resolved
src/Mocha/src/Mocha/Middlewares/Consume/ConsumerInstrumentationMiddleware.cs
Show resolved
Hide resolved
src/Mocha/src/Mocha/Observability/Configuration/InstrumentationBusExtensions.cs
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9488 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.