France-ioi / AlgoreaBackend

Backend for the new Algorea platform
MIT License
1 stars 2 forks source link

Add request id in sql logs #1075

Open smadbe opened 2 months ago

smadbe commented 2 months ago

Motivations

When we debug (especially long sql request), it is important to be able to isolate in a log stream all logs related to a given http request. Then applying a filter on the log stream would be easy.

Subtasks

For instance, currently the attributes are:

{
    "duration": 0.005858055,
    "err": null,
    "level": "info",
    "msg": "sql-stmt-exec",
    "query": "INSERT INTO `groups` (`created_at`, `id`, `is_open`, `send_emails`, `type`) VALUES (NOW(), 8041981013378713026, \"false\", \"false\", \"User\")",
    "time": "2024-05-14T14:54:48Z",
    "ts": "2024-05-14 14:54:48",
    "type": "db"
}

EDIT: request going through lambda should have a x-amzn-trace-id header that could be used for that, but we should find a way it in a way which does not hardcode this aws-specific header name in the code