[Improvement] TraceId Implementation for Audit Logs in Gravitino
What would you like to be improved?
Currently, for Gravitino's audit logs, there is no concept of traceId that runs through the entire user request, processing, and response return. Especially since we may later connect Gravitino to various engines, and in our actual production practice, the logs and requests related to the engine will include a traceId, which may contain specific information corresponding to an ETL task's appId, user, etc. As a link in the call chain of a task, Gravitino also hopes to include this traceId in the entire call, processing, and response chain, so that a full link tracking of a task can be carried out, and it is known which task a failure specifically corresponds to. In particular, it is very necessary to include this traceId in all logs related to a request.
How should we improve?
No response
seems we could you MDC to implement this
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String requestId = req.getHeader("X-Request-ID");
MDC.put("requestId", requestId);
try {
log.info("Processing request");
resp.getWriter().write("Request processed");
} finally {
MDC.clear();
}
}