blob: 8430e97ad14174fb87b23ee83e3b5042877a6d34 [file] [log] [blame]
Edwin Kempin0ade5aa2018-08-10 08:49:32 +02001= Request Tracing
2
3Gerrit supports on-demand tracing of single requests that results in
4additional logs with debug information that are written to the
5`error_log`. The logs that correspond to a traced request are
6associated with a unique trace ID. This trace ID is returned with the
7response and can be used by an administrator to find the matching log
8entries.
9
10How tracing is enabled and how the trace ID is returned depends on the
11request type:
12
13* REST API: For REST calls tracing can be enabled by setting the
Edwin Kempin99ccd922018-09-10 10:06:53 +020014 `trace` request parameter or the `X-Gerrit-Trace` header, the trace
15 ID is returned as `X-Gerrit-Trace` header. More information about
16 this can be found in the link:rest-api.html#tracing[Request Tracing]
17 section of the link:rest-api.html[REST API documentation].
Edwin Kempin0ade5aa2018-08-10 08:49:32 +020018* SSH API: For SSH calls tracing can be enabled by setting the
19 `--trace` option. More information about this can be found in
20 the link:cmd-index.html#trace[Trace] section of the
21 link:cmd-index.html[SSH command documentation].
22* Git: For Git pushes tracing can be enabled by setting the
23 `trace` push option, the trace ID is returned in the command output.
24 More information about this can be found in
25 the link:user-upload.html#trace[Trace] section of the
26 link:user-upload.html[upload documentation]. Tracing for Git requests
27 other than Git push is not supported.
28
Edwin Kempinda823782018-08-29 22:52:54 +020029When request tracing is enabled it is possible to provide an ID that
30should be used as trace ID. If a trace ID is not provided a trace ID is
31automatically generated. The trace ID must be provided to the support
32team so that they can find the trace.
33
34When doing traces it is recommended to specify the ID of the issue
35that is being investigated as trace ID so that the traces of the issue
36can be found more easily. When the issue ID is used as trace ID there
37is no need to find the generated trace ID and report it in the issue.
38
Edwin Kempinc9ec7782018-08-29 08:45:51 +020039Since tracing consumes additional server resources tracing should only
40be enabled for single requests if there is a concrete need for
41debugging. In particular bots should never enable tracing for all their
42requests by default.
43
Edwin Kempin0ade5aa2018-08-10 08:49:32 +020044== Find log entries for a trace ID
45
46If tracing is enabled all log messages that correspond to the traced
47request have a `TRACE_ID` tag set, e.g.:
48
49----
50[2018-08-13 15:28:08,913] [HTTP-76] TRACE com.google.gerrit.httpd.restapi.RestApiServlet : Received REST request: GET /a/accounts/self (parameters: [trace]) [CONTEXT forced=true TRACE_ID="1534166888910-3985dfba" ]
51[2018-08-13 15:28:08,914] [HTTP-76] TRACE com.google.gerrit.httpd.restapi.RestApiServlet : Calling user: admin [CONTEXT forced=true TRACE_ID="1534166888910-3985dfba" ]
52[2018-08-13 15:28:08,942] [HTTP-76] TRACE com.google.gerrit.httpd.restapi.RestApiServlet : REST call succeeded: 200 [CONTEXT forced=true TRACE_ID="1534166888910-3985dfba" ]
53----
54
55By doing a grep with the trace ID over the error log the log entries
56that correspond to the request can be found.
Edwin Kempince92339b2018-08-29 09:56:16 +020057
58== Which information is captured in a trace?
59
60* request details
61** REST API: request URL, request parameter names, calling user,
62 response code, response body on errors
63** SSH API: parameter names
64** Git API: push options, magic branch parameter names
65* cache misses, cache evictions
66* reads from NoteDb, writes to NoteDb
67* reads of meta data files, writes of meta data files
68* index queries (with parameters and matches)
69* reindex events
70* permission checks (e.g. which rule is responsible for a deny)
Edwin Kempineb17f3b2018-08-29 10:31:33 +020071* timer metrics
Edwin Kempince92339b2018-08-29 09:56:16 +020072* all other logs