Ecto & DBConnection logging metadata

We use Ecto extensively on a very high-load server (think like millions of requests a day). Recently we’ve been having some db_connection issues and wanted to tune our configuration.

We can always resort to dynamic instrumentation for this, but one simple thing could make this really easier: pass a “request_id” or “flow_id” or anything else to ecto and db_connection so that we can trace it easily through a log viewer. Currently, Logger metadata don’t inherit parent process metadata and there is no way to pass this through current calls (I think at least).

So here is the question: Is there a way to ensure that a request_id generated by Plug.RequestId for example would me passed down to child processes?

What I specifically would want is errors to have a request_id.

Thanks you all in advance!

2 Likes