drajer-health / eCRNow

Repository for eCRNow app.
Apache License 2.0
41 stars 55 forks source link

Add RequestId to all logged events #492

Closed martha-garasky closed 1 month ago

martha-garasky commented 1 year ago

In order better follow the lifecycle of a triggered message, can we add the requestId from the trigger event into all logged events. Making this a configurable option also is ok.

So a log would go from looking like this: 2023-04-09 21:44:27.740 ERROR 1 --- [pool-1-thread-2] c.d.b.e.s.i.EhrFhirR4QueryServiceImpl : No entries found for type : MedicationRequest

to something like this: 2023-04-09 21:44:27.740 ERROR 1 --- [pool-1-thread-2] c.d.b.e.s.i.EhrFhirR4QueryServiceImpl : RequestId: <id> -- No entries found for type : MedicationRequest

This additional item in the log message will help making parsing easier when using external logging tools such as splunk.

nbashyam commented 1 year ago

Will consider it for a future sprint.

kmarx commented 3 months ago

I'd like to upvote this. Wherever the x-request-id or correlation-id are available, they should be logged. In addition to the rationale provided by @martha-garasky, our EHR has multiple practices and this would allow us to track volume and load with better granularity since we bake the practice id into the x-request-id.

I'd also like to add a request that logging be more complete for other use cases even when x-request-id isn't in scope. E.g.,

nbashyam commented 1 month ago

We have added xRequestId to start / end of the task execution, so all messages from the thread within that context is for the same request id. Currently it is not possible to change each log statement to add xRequestId.