Files
gerrit/java
Edwin Kempin 39eb22bf28 Support tracing for single REST requests
To investigate why a certain REST call failed one needs to find matching
messages in the logs. Sometimes this is not as easy as it sounds:

1) Error reports may not tell exactly which REST endpoint was invoked
   and what were the IDs of the REST resources on which it was invoked.
2) For busy servers finding logs that correspond to the failing REST
   call may be difficult because of the huge amount of logs. Matching
   logs by the timestamp of when the request was done may also not be
   straight-forward if the user is in a different timezone than the
   server.
3) The error log normally only contains errors, but no detailed debug
   information.
4) Enabling debug logs effects all requests and usually results in a lot
   of log spam.

The idea is to enable debug traces on need for single requests:

a) A debug trace is enabled by setting the 'trace' request parameter
b) The response contains an 'X-Gerrit-Trace' header with the trace ID
c) An administrator can use the trace ID to find all logs for this
   request in the error log.
d) The debug trace can contain additional debug information which is not
   written when tracing is disabled.

This change implements a), b) and c) for REST requests. If the trace
parameter is set for a REST request we open a trace context that sets a
logging tag with a generated trace ID that is then automatically
included into all log statements that are triggered by this request. The
trace ID is returned to the client as 'X-Gerrit-Trace' header in the
response.

d) will be implemented by a follow-up change which will make use of
Flogger's force log functionality.

Change-Id: Ic79aadedbe5d73e94daefa6aa9d207edbffc1607
Signed-off-by: Edwin Kempin <ekempin@google.com>
2018-08-14 17:21:24 +02:00
..
2018-08-14 08:07:59 +02:00