User:Phuedx/Metrics Platform

From Wikitech

The Metrics Platform is a suite of services, standard libraries, and APIs for producing and consuming data of all kinds from Wikimedia Foundation products..

The Metrics Platform provides standardized algorithms, behaviors, and basic necessities for web and app instrumentation, including:

  • standardized session ID generation, consistent across MediaWiki, Android, and iOS
  • standardized session expiry
  • enriching events with contextual data
  • determining which events are in-sample or out-of-sample based on a specific identifier (currently: pageview, session, or app install ID)

Quick Start

Currently, the JS and PHP Metrics Platform Clients only work within the EventLogging extension. Before we get started defining streams and creating instruments, you will need to have an up-to-date MediaWiki development environment. If you do not have one, then please consider using MediaWiki-Docker.

Setup and Hello, World!

See this Event Platform configuration recipe for MediaWiki-Docker for detailed instructions about setting up an Event Platform (ish) environment alongside your MediaWiki development environment. Afterwards, add this to LocalSettings.php:

$wgEventStreams = [
    'test.all' => [
        'schema_title' => '/analytics/mediawiki/client/metrics_event',
        'producers' => [
            'metrics_platform_client' => [
                'events' => [ '' ], // Matches all event names
            ],
        ],
    ],
];
$wgEventLoggingStreamNames = [ 'test.all' ];

Navigate to http://localhost:8080/wiki/Main_Page and run this in the console:

mw.eventLog.dispatch( 'test.hello_world', {
    hello: 'World!'
} );

Rationale

Previously, different teams implemented their own analytics solutions in isolated from one another. Those solutions were typically based on the Legacy EventLogging pipeline and, more recently, the Event Platform. The Metrics Platform is an effort to unify that previous work and to establish uniformity and consistency across platforms.

It will be easier to leverage data from multiple platforms to yield insights into how our users use our whole ecosystem of products in unison.

It will be easier for analysts to support teams which are not their primary teams. Previously, every instrument has its own quirks and conventions, which need to be remembered by analyst that works with the data produced by the instrument – including analysts that are providing temporary support.

It will be easier to implement and maintain instruments. The Metrics Platform will provide the APIs and protocols that MediaWiki developers need to create sophisticated instruments in as few lines of code as possible while maintaining quality, rigor, and safety.

Further Reading

Getting Started

Metrics Platform/Getting Started/Creating An Instrument

Metrics Platform/Getting Started/Hacking On Metrics Platform

How To

Metrics Platform/Creating a Stream Configuration

Reference Guides

Metrics Platform/Implementations - The APIs provided by each Metrics Platform Client implementation and the key differences between them

Metrics Platform/Identifiers

Metrics Platform/Event Schema - The specification of the monoschema

FAQ

Metrics Platform/FAQ

Archive

The following pages were archived while this page and its subpages were rewritten: