NServiceBus
NServiceBus copied to clipboard
There's no extension point to add custom properties to log entries for failed messages
This issue was transferred from a private repository
Our processing pipeline allows customer to create a logging scope in a custom behavior. Within this scope all log entries can include custom properties. This allows a customer to add diagnostics info for correlating important identifiers to a log entry. For example, all log entries can include a custom transaction identifier, a message identifier, or any other identifier important for diagnostics.
The problem is that failures are logged via the RecoverabilityExecutor, this is invoked from the transport after a processing failure. This happens after the pipeline is already closed. A "error" pipeline that allows custom stage behaviors or connectors does not exist. Any log entries written cannot be extended to include meta data.
Non optimal workarounds:
- Behavior that managed a scope but that also logs errors: https://gist.github.com/ramonsmits/db71a2a716c438c641b179786ba1c2f8
- Create a custom recoverability policy that writes a log entry that contains these properties for failures.
Some potential solution suggestions:
- Creating a error pipeline that allows customizations
- Support logging scopes natively in core and downstreams and provide during error processing that allows customer to add their own custom diagnostics properties
FYI the v8 recoverability pipeline might be helpful in addressing this:
https://docs.particular.net/nservicebus/recoverability/pipeline