Earlier quoted context omitted.
You don’t need to go this path; modern(-ish) APM systems like Datadog will let you trace SQL commands in the context of the request being made. You can group by endpoint, or group by sql (merging IDs that differ), or chop and filter the data however you need. The DB is not in a position to give you all the stats you need; instead the DB should support e.g. exporting plan info to further enrich the whole-request metri…
I've used Datadog but if you need per query tracing from the database logs, I think the only way is to embed a trace ID in a SQL comment (or in an no-op column) like the grandparent showed. Datadog is tracing the request from the application akin to something like openTrace("Query Name", queryStr) db.Query(queryStr) closeTrace() The gap with that style of application-level tracing is that the database logs give no in…
What are you getting from the DB logs that you can't get elsewhere?