Just a quick inquiry.
in a chain of services (one calling another), I’d like to create and maintain a unique identifier that can be used to correlate logging entries across all the related calls through the services. (There is only one shared log).
Is there any mechanism or support in SS for this kind of thing?
I imagine conceptually that every service in the chain would look at the request for an existing correlationId (somewhere, i.e. headers) and if not present, would then create one, save it the request, and pass it through (somewhere, i.e. headers) to calls to other downstream services. Who then repeat the same logic.
The correlationId is then somehow copied to the logger of each service for inclusion in logs.
No we don’t have explicit support for correlation ids.
2 approaches come to mind: implementing an explicit IHasCorrelationId interface on Request and Response DTO’s and have Request and Response Filters automatically populate them. In the Response Filter you can get the original Request DTO from IRequest.Dto.
An implicit approach would be to pass them in HTTP Headers and have Request Filters drop it into the IRequest.Items Dictionary so it’s available throughout the pipeline where a Response Filter could add it back to the HTTP Response Headers.