Add override config for instrumentation rates

Bug: T250086
Change-Id: I32fbf3d6562fb0a93698a24bbd8177149a19fed3
This commit is contained in:
David Lynch 2020-04-13 10:30:20 -05:00
parent 7ba060dcd7
commit e38aad96e4
3 changed files with 32 additions and 2 deletions

View file

@ -203,6 +203,7 @@
},
"Hooks": {
"BeforePageDisplay": "DiscussionToolsHooks::onBeforePageDisplay",
"ResourceLoaderGetConfigVars": "DiscussionToolsHooks::onResourceLoaderGetConfigVars",
"GetBetaFeaturePreferences": "DiscussionToolsHooks::onGetBetaPreferences",
"ListDefinedTags": "DiscussionToolsHooks::onListDefinedTags",
"ChangeTagsListActive": "DiscussionToolsHooks::onListDefinedTags",
@ -220,6 +221,14 @@
"DiscussionToolsUseVisualEditor": {
"value": false,
"description": "Use VisualEditor for editing replies (both visual and wikitext)."
},
"DTSchemaEditAttemptStepSamplingRate": {
"value": false,
"description": "Rate at which to sample sessions for instrumentation; overrides WikimediaEvents rate if set"
},
"DTSchemaEditAttemptStepOversample": {
"value": false,
"description": "Oversample EditAttemptStep logging; distinct from rate tuning, as it'll flag the events as being oversampled"
}
},
"ConfigRegistry": {

View file

@ -80,6 +80,23 @@ class DiscussionToolsHooks {
}
}
/**
* Set static (not request-specific) JS configuration variables
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
* @param array &$vars Array of variables to be added into the output of the startup module
* @param string $skinName Current skin name to restrict config variables to a certain skin
*/
public static function onResourceLoaderGetConfigVars( &$vars, $skinName ) {
$dtConfig = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'discussiontools' );
$vars['wgDTSchemaEditAttemptStepSamplingRate'] =
$dtConfig->get( 'DTSchemaEditAttemptStepSamplingRate' );
$vars['wgDTSchemaEditAttemptStepOversample'] =
$dtConfig->get( 'DTSchemaEditAttemptStepOversample' );
}
/**
* Handler for the GetBetaPreferences hook, to add and hide user beta preferences as configured
*

View file

@ -18,7 +18,8 @@ mw.loader.using( 'ext.eventLogging' ).done( function () {
var // Schema class is provided by ext.eventLogging
Schema = mw.eventLog.Schema,
user = mw.user,
sampleRate = mw.config.get( 'wgWMESchemaEditAttemptStepSamplingRate' ),
sampleRate = mw.config.get( 'wgDTSchemaEditAttemptStepSamplingRate' ) ||
mw.config.get( 'wgWMESchemaEditAttemptStepSamplingRate' ),
actionPrefixMap = {
firstChange: 'first_change',
saveIntent: 'save_intent',
@ -180,7 +181,10 @@ mw.loader.using( 'ext.eventLogging' ).done( function () {
} else {
schemaEditAttemptStep.log(
data,
mw.config.get( 'wgWMESchemaEditAttemptStepOversample' ) ? 1 : sampleRate
(
mw.config.get( 'wgDTSchemaEditAttemptStepOversample' ) ||
mw.config.get( 'wgWMESchemaEditAttemptStepOversample' )
) ? 1 : sampleRate
);
}
} );