wiki.techinc.nl/includes/debug/logger
Ori Livneh 5360a3497f Provide a unique request identifier
When MediaWiki encounters an unhandled exception, the error message it produces
includes a randomly-generated token, which allows the exception details to be
looked up in the error logs. This is useful but narrow: would it not be useful
to have the ability to retrieve all log records associated with a particular
request, rather than just exception details? (Hint: yes.)

So: introduce the notion of a request-global unique ID, retrievable via
WebRequest::getRequestId(). When MediaWiki is behind Apache + mod_unique_id
(which provides the same facility) or some other software which sets a
UNIQUE_ID envvar, the value of that envvar is used as the request ID.
Otherwise, it is a randomly-generated 24-character string.

The request ID supplants exception-specific IDs; MWExceptionHandler::getLogId()
is deprecated, accordingly. The request ID is also added as an annotation to
all Monolog-processed log records, and is exposed client-side as 'wgRequestId'.
This allows developers to associate a page view with log records even when the
page view does not result in an unhandled exception. (For the WMF, I also
intend to add it as an annotation to profiling data).

The request ID is not a tracking token; it does not persist, and it is
associated with a backend request, not with a particular user or a particular
session. Like the data in the NewPP report, the request ID is designed to be
cacheable, so that if, for example, a developer notices something weird in the
HTML, s/he can associate the output with a backend request regardless of
whether the response was served from the cache or directly from the backend.

Some prior art:
* https://httpd.apache.org/docs/2.4/mod/mod_unique_id.html
* http://api.rubyonrails.org/classes/ActionDispatch/RequestId.html
* https://github.com/dabapps/django-log-request-id
* https://packagist.org/packages/php-middleware/request-id
* https://github.com/rhyselsmore/flask-request-id

Change-Id: Iaf90c20c330e0470b9b98627a0228cadefd301d1
2016-03-25 16:09:05 +00:00
..
monolog Provide a unique request identifier 2016-03-25 16:09:05 +00:00
LegacyLogger.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
LegacySpi.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
LoggerFactory.php Remove various double empty newlines 2015-12-27 18:55:12 +00:00
MonologSpi.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
NullSpi.php Remove various double empty newlines 2015-12-27 18:55:12 +00:00
Spi.php Remove redundant escaping for namespace references in documentation 2015-11-23 23:02:32 +00:00