At Ampersand we are always trying to improve our ability to support our clients. This occasionally calls for the creation of a Magento module, which we are always happy to open source as an active participant and contributor within Magento/Adobe Commerce tech communities.
The Ampersand_LogCorrelationId is the latest Magento 2 module we’ve built and released. It is a Magento module that helps us drill into a specific process with much greater speed and accuracy.
This module allows you to add a correlation ID (also known as a Trace ID) to your Magento logs, access logs and New Relic transactions.
A correlation ID is a unique, randomly generated identifier that is added to every request and response. Adding this identifier to your logs means that you no longer have to filter or group logs by the time. Instead, you are able to group logs by request or process, making it an amazingly useful feature.
Debug critical issues
The tool is also useful for debugging intermittent issues. As you add logs to your system it can sometimes be difficult to group the logs produced by a valid process versus a failing process. With this approach, you can easily grab all data for a valid process and compare it to the failing process to see where it differs. This will allow you to debug critical issues with greater speed and efficiency.
Possible Use Examples:
– If you saw an errant 503 in your access logs you would be able to look at the `X-Log-Correlation-Id` header and then query your Magento log files for the same identifier. All logs for only that request will be visible.
– If you saw something in your log files and you could not figure out what triggered it, you could get the correlation identifier and cross-reference it with access logs to see the request which triggered it.
– If you saw something unusual in a New Relic transaction you could easily find the corresponding Magento and access logs.
– If you are working on more complex distributed systems. You could add this correlation ID to requests to downstream systems, this would allow you to follow data through the system.
To start using the module, visit:
You may also benefit from this popular Tech Share article on how to disable Magento 2 stock reservations or check out our growing suite of helpful Magento module Tech Shares on our GitHub page