wiki.techinc.nl/includes/exception
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
..
BadTitleError.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
ErrorPageError.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
FatalError.php
HttpError.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
MWException.php Provide a unique request identifier 2016-03-25 16:09:05 +00:00
MWExceptionHandler.php Provide a unique request identifier 2016-03-25 16:09:05 +00:00
PermissionsError.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
ReadOnlyError.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00
ThrottledError.php Set ThrottledError's response code to 429 2014-03-28 12:25:59 +02:00
TimestampException.php Move TimestampException to exception directory 2014-10-06 11:03:54 +02:00
UserBlockedError.php
UserNotLoggedIn.php Convert all array() syntax to [] 2016-02-17 01:33:00 -08:00