Before we look into Tracing module, we need to discuss on Correlation Id and it's importance..!
What is Correlation Id.?
For eg, In a trip planning application, we send customer_details request to various applications (apis), so this message is consumed by Hotel API, Airline API and Car-Rental microservices. These separate services respond asynchronously. Where multiple responses and requests are flowing across distributed microservices, so with the help of Correlation Id we can track the particular transaction easily.
Use the correlation ID to understand the entire history of an event that resulted in an issue or an unhandled error (all errors include the correlation ID of the event that triggered it). Also, knowing the correlation ID helps you perform a memory analysis of heap dumps.
To obtain a correlation ID, Mule first checks for one in the source message (for example, a JMS message or an HTTP listener with the X-CORRELATION-ID header). If the source does not set a correlation ID, Mule generates one using the correlation ID generator.
In earlier version of Mule Runtime, Correlation Id can't be modified.
But in Mule 4.4.0 or later version, Correlation Id can be modified with the help of Tracing Module.
Tracing module enables us to enhance the logs by adding, removing, and clearing all variables from the logging context for a given Mule event. It also enables us to modify the correlation ID during flow execution.
Tracking Module:
You need to download this module from Exchange.
- Clear all the logging variables from the event logging context.
- Remove a logging variable from logging context.
- Set logging variables to logging context.
- Modify the correlation ID during flow execution
Create a simple flow, drag and drop With CorrelationID and specify correlation Id as shown in below screenshot.
Ref: docs.mulesoft.com
Thanks for reading :-)
No comments:
Post a Comment