MediaWiki  master
Wikimedia\Stats\StatsUtils Class Reference

StatsUtils Implementation. More...

Static Public Member Functions

static getFilteredSamples (float $sampleRate, array $samples)
 Returns a subset of samples based on configured sample rate. More...
 
static mergeLabels (array $leftLabels, array $rightLabels)
 Merges two associative arrays of labels. More...
 
static normalizeArray (array $entities)
 Normalize an array of strings. More...
 
static normalizeString (string $entity)
 Normalize strings to a metrics-compatible format. More...
 
static validateLabelKey (string $key)
 Determines if provided string is a valid label key. More...
 
static validateLabelValue (string $value)
 
static validateMetricName (string $name)
 Determines if provided string is a valid name. More...
 
static validateNewSampleRate (float $newSampleRate)
 Validates the new sample rate. More...
 

Detailed Description

StatsUtils Implementation.

Functionality common to all metric types.

Author
Cole White
Since
1.38

Definition at line 36 of file StatsUtils.php.

Member Function Documentation

◆ getFilteredSamples()

static Wikimedia\Stats\StatsUtils::getFilteredSamples ( float  $sampleRate,
array  $samples 
)
static

Returns a subset of samples based on configured sample rate.

Parameters
float$sampleRate
array$samples
Returns
array

Definition at line 63 of file StatsUtils.php.

◆ mergeLabels()

static Wikimedia\Stats\StatsUtils::mergeLabels ( array  $leftLabels,
array  $rightLabels 
)
static

Merges two associative arrays of labels.

Prioritizes leftmost labels.

Parameters
array$leftLabels
array$rightLabels
Returns
array

Definition at line 124 of file StatsUtils.php.

◆ normalizeArray()

static Wikimedia\Stats\StatsUtils::normalizeArray ( array  $entities)
static

Normalize an array of strings.

Parameters
string[]$entities
Returns
string[]

Definition at line 144 of file StatsUtils.php.

◆ normalizeString()

static Wikimedia\Stats\StatsUtils::normalizeString ( string  $entity)
static

Normalize strings to a metrics-compatible format.

Replace any other non-alphanumeric characters with underscores. Eliminate repeated underscores. Trim leading or trailing underscores.

Parameters
string$entity
Returns
string

Definition at line 162 of file StatsUtils.php.

Referenced by Wikimedia\Stats\StatsFactory\__construct(), and Wikimedia\Stats\Metrics\BaseMetric\__construct().

◆ validateLabelKey()

static Wikimedia\Stats\StatsUtils::validateLabelKey ( string  $key)
static

Determines if provided string is a valid label key.

Parameters
string$key
Returns
void
Exceptions
InvalidArgumentException
InvalidConfigurationException

Definition at line 102 of file StatsUtils.php.

◆ validateLabelValue()

static Wikimedia\Stats\StatsUtils::validateLabelValue ( string  $value)
static

Definition at line 111 of file StatsUtils.php.

◆ validateMetricName()

static Wikimedia\Stats\StatsUtils::validateMetricName ( string  $name)
static

Determines if provided string is a valid name.

Parameters
string$name
Returns
void
Exceptions
InvalidArgumentException
InvalidConfigurationException

Definition at line 85 of file StatsUtils.php.

◆ validateNewSampleRate()

static Wikimedia\Stats\StatsUtils::validateNewSampleRate ( float  $newSampleRate)
static

Validates the new sample rate.

Throws InvalidArgumentException if provided an invalid rate.

Parameters
float$newSampleRate
Exceptions
InvalidArgumentException

Definition at line 50 of file StatsUtils.php.


The documentation for this class was generated from the following file: