Tracing is automatically enabled for all HTTP requests. You can view the trace endpoint
and obtain basic information about the last 100 requests. The following listing shows
sample output:
[{ "timestamp": 1394343677415, "info": { "method": "GET", "path": "/trace", "headers": { "request": { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Connection": "keep-alive", "Accept-Encoding": "gzip, deflate", "User-Agent": "Mozilla/5.0 Gecko/Firefox", "Accept-Language": "en-US,en;q=0.5", "Cookie": "_ga=GA1.1.827067509.1390890128; ..." "Authorization": "Basic ...", "Host": "localhost:8080" }, "response": { "Strict-Transport-Security": "max-age=31536000 ; includeSubDomains", "X-Application-Context": "application:8080", "Content-Type": "application/json;charset=UTF-8", "status": "200" } } } },{ "timestamp": 1394343684465, ... }]
By default, the trace includes the following information:
| Name | Description |
|---|---|
Request Headers | Headers from the request. |
Response Headers | Headers from the response. |
Cookies |
|
Errors | The error attributes (if any). |
Time Taken | The time taken to service the request in milliseconds. |
If you need to trace additional events, you can inject a
TraceRepository into your
Spring beans. The add method accepts a single Map structure that is converted to JSON
and logged.
By default, an InMemoryTraceRepository that stores the last 100 events is used. If you
need to expand the capacity, you can define your own instance of the
InMemoryTraceRepository bean. You can also create your own alternative
TraceRepository implementation.