Extension:NavigationTiming

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.svg
NavigationTiming

Release status:Extension status stable

ImplementationTemplate:Extension#type Ajax
DescriptionTemplate:Extension#description Logs perceived latency measurements from client-side
Author(s)Template:Extension#username Patrick Reilly, Ori Livneh, Asher Feldman, Timo Tijhof, Ian Marlier
Compatibility policyCompatibility#mediawiki_extensions release branches
Database changesTemplate:Extension#needs-updatephp No
LicenseTemplate:Extension#license GNU General Public License 2.0 or later
Download
README
ParametersTemplate:Extension#parameters
* $wgNavigationTimingSamplingFactor
Hooks usedTemplate:Extension#hook
BeforePageDisplayManual:Hooks/BeforePageDisplay
ResourceLoaderGetConfigVarsManual:Hooks/ResourceLoaderGetConfigVars

Translate the NavigationTiming extension if it is available at translatewiki.net

Check usage and version matrix.

IssuesPhabricator

Open tasks · Report a bug

The NavigationTiming extension allows logging perceived latency measurements, exposed by browsers as part of the W3C Navigation Timing spec, which "defines an interface for web applications to access timing information related to navigation and elements".

Scope[edit]

Browsers accounting for upto 5% of Wikimedia traffic (as of November 2017)[1] may not be included in the results due these browsers not supporting Grade A for MediaWiki and/or the Navigation Timing API. See also https://caniuse.com/nav-timing.

How is the information used?[edit]

Engineers at Wikimedia Foundation intend to use this data to assess the impact (positive and negative) of changes to code or server configuration, and thus to help guide ongoing work on site performance.

Sample configuration[edit]

wfLoadExtension( 'EventLogging' ); // required dependency
wfLoadExtension( 'NavigationTiming' );
$wgNavigationTimingSamplingFactor = 10000;  // log 1:10,000 requests.
$wgNavigationTimingOversampleFactor = [
    'geo' => [
        'US' => 5
    ],
    'userAgent' => [
        'Chrome' => 100
    ]
];

Oversampling[edit]

Oversampling allows us to selectively sample a larger portion of the traffic coming from a particular geography, or with a specific User Agent string in the browser. Use cases for this include: getting detailed observations of the change in performance based on factors like data center location; or evaluating the change in performance due to things like browser upgrades (eg, the release of Firefox 57, which had significant rewrites that were intended to improve performance).

Oversampling is configured using the wgNavigationTimingOversampleFactor variable. This variable is an associative array, and the keys that are checked are "geo" and "userAgent".

If the user's country code is included in the 'geo' array, then a sample is taken with frequency 1/samplerate. If the user's browser has a User Agent string that matches a key in the userAgent array, then a sample is taken with frequency 1/samplerate. No more than 1 oversample is taken for a given request.

If the request is oversampled, the emitted event will include these properties:

  • isOversample: true
  • oversampleReason: string, whose contents are a JSON array of reasons that the oversample happened. These will be of the form "geo:XX" (where XX is the country code that matched), or "ua:ABCDEF" (where ABCDEF is the string that was found in the browser's User Agent string)

Further reading[edit]

About the data we collect:

About the Navigation Timing API in web browsers:

Code stewardship[edit]

Footnotes[edit]