Page MenuHomePhabricator

Update Sample Rates for Metrics Platform Events
Closed, ResolvedPublic2 Estimated Story Points

Description

We have identified that the sample rates for events originating from Metrics Platform on both mobile and desktop platforms are currently set to 100% across all instances. We need to update these sample rates to accurately reflect the current sample rate configured for Event Platform as seen here.

Action Items:

  • Adjust the sample rates for events sourced from Metrics Platform on both mobile and desktop platforms to align with the current sample rate settings for Event Platform.

[] Given that there is already a solution implemented for the web_ui_scroll event, we can hopefully replicate the same fix for desktopwebuiactions and mobilewebuiactions

Sign Off:

  • Ensure that sample rates can be verified locally.
  • Collaborate with Data Engineering/MP Team on fix and have one +1 from this team
  • A follow-up ticket has been created for testing post-implementation to validate that the sample rate adjustments have been correctly applied. T365489

Event Timeline

Change #1017378 had a related patch set uploaded (by Kimberly Sarabia; author: Kimberly Sarabia):

[operations/mediawiki-config@master] Remove sampling rate in config for MP events

https://gerrit.wikimedia.org/r/1017378

@phuedx -

@jwang and I were discussing whether it is possible to accurately capture the correct sample rate instead of returning NULL? Right now, this is what it looks like with this query for scroll specifically:

SELECT sample
from mediawiki_web_ui_scroll_migrated
limit 5

image (1).png (494×702 px, 32 KB)

Having this column would be helpful, so any hints you can share would be highly appreciated.

I agree that it would be valuable to capture the sampling config for the instrument (not just for this instrument either).

Data Products also thinks that, generally, it would be valuable for teams to be able to use the sampling config embedded in the stream config as:

  1. Instrument Maintainers don't have to create their own sampling config and thread it through to the instrument, which, generally, makes it harder to reconstruct what sampling rate was used when after the fact
  2. Data Products is making a UI that will allow you to tweak the sampling config of an instrument 🎉🎉🎉
  3. It can make the instruments simpler

However, WebUIScroll does conditional oversampling – if you're logged in, then the stream is always in sample; otherwise, use the value of $wgWMEWebUIScrollTrackingSamplingRateAnons as the stream sampling rate.

Here are a couple of ways that I can see Metrics Platform supporting this pattern:

Passing the sample config at call time
mw.eventLog.submitInteraction(
  STREAM_NAME,
  SCHEMA_NAME,
  actionName,
  interactionData,
  sampleConfig
);

If the sample config is passed, then it overrides the sample config from the stream config.

Passing the sample config during instrument setup
mw.eventLog.overrideStreamSampleConfig(
  STREAM_NAME,
  sampleConfig
);

// …

mw.eventLog.submitInteraction(
  STREAM_NAME,
  SCHEMA_NAME,
  actionName,
  interactionData
);

If called, the Metrics Platform client library will use the sample config from #overrideStreamSampleConfig().

Support curation-rule-like rules in the stream config
$wgEventStreams = [
  'STREAM_NAME' => [
    // …
    'sample' => [
      [
        'unit' => 'session',
        'rate' => 0.1,
      ],
      [
        'unit' => 'session',
        'rate' => 0.1,
        'if' => [
          'performer_is_logged_in' => true,
        ],
      ],
    ],
  ],
];

In all cases, the Metrics Platform client libraries would be updated to always capture the sample config.

My preference would be for #3 (Support curation-rule-like rules in the stream config) as it keeps the stream config as the single source of the truth/keeps the instrument simple.

Support curation-rule-like rules in the stream config
$wgEventStreams = [
  'STREAM_NAME' => [
    // …
    'sample' => [
      [
        'unit' => 'session',
        'rate' => 0.1,
      ],
      [
        'unit' => 'session',
        'rate' => 0.1,
        'if' => [
          'performer_is_logged_in' => true,
        ],
      ],
    ],
  ],
];

Thinking about it, this would be better expressed as:

$wgEventStreams = [
  'STREAM_NAME' => [
    // …
    'sample' => [
      'unit' => 'session',
      'rate' => 0.1,
    ],
    'sample_overrides' => [
      [
        'unit' => 'session',
        'rate' => 0.1,
        'if' => [
          'performer_is_logged_in' => true,
        ],
      ],
    ],
  ],
];

It's clearer/easier to validate and is backwards compatible with stream configs/stream config parsers that are in production.

Change #1024813 had a related patch set uploaded (by Kimberly Sarabia; author: Kimberly Sarabia):

[operations/mediawiki-config@master] Introduce sample overrides to web_ui_actions

https://gerrit.wikimedia.org/r/1024813

Change #1017378 abandoned by Kimberly Sarabia:

[operations/mediawiki-config@master] Remove sampling rate in config for MP events

Reason:

See 1024813

https://gerrit.wikimedia.org/r/1017378

Change #1024813 merged by jenkins-bot:

[operations/mediawiki-config@master] Introduce sample overrides to web_ui_actions

https://gerrit.wikimedia.org/r/1024813

Mentioned in SAL (#wikimedia-operations) [2024-05-20T20:06:48Z] <urbanecm@deploy1002> Started scap: Backport for [[gerrit:1024813|Introduce sample overrides to web_ui_actions (T361962)]], [[gerrit:1031610|Disable wgParserEnableLegacyMediaDOM (T363597)]], [[gerrit:1031458|Disable last remaining projects using share user scripts (T301212)]]

Mentioned in SAL (#wikimedia-operations) [2024-05-20T20:09:25Z] <urbanecm@deploy1002> urbanecm and jdlrobson and ksarabia: Backport for [[gerrit:1024813|Introduce sample overrides to web_ui_actions (T361962)]], [[gerrit:1031610|Disable wgParserEnableLegacyMediaDOM (T363597)]], [[gerrit:1031458|Disable last remaining projects using share user scripts (T301212)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-05-20T20:25:06Z] <urbanecm@deploy1002> Finished scap: Backport for [[gerrit:1024813|Introduce sample overrides to web_ui_actions (T361962)]], [[gerrit:1031610|Disable wgParserEnableLegacyMediaDOM (T363597)]], [[gerrit:1031458|Disable last remaining projects using share user scripts (T301212)]] (duration: 18m 18s)

Jdlrobson claimed this task.

QA will be done as part of T365489