MediaWiki  master
Wikimedia\Metrics\MetricUtils Class Reference
Collaboration diagram for Wikimedia\Metrics\MetricUtils:

Public Member Functions

 addSample (Sample $sample)
 Adds a sample to cache. More...
 
 render ()
 
 setTypeIndicator (string $typeIndicator)
 Sets the StatsD protocol type indicator. More...
 
 validateConfig ( $config)
 
 validateLabels (array $labels)
 

Protected Attributes

string $extension
 
string $format
 
string[] $labels
 
string $name
 
string $prefix
 
float $sampleRate
 
Sample[] $samples = []
 
string $typeIndicator
 

Private Member Functions

 getFilteredSamples ()
 Get set of samples filtered according to configured sampleRate. More...
 
 renderDogStatsD (Sample $sample)
 Renders metrics in DogStatsD format https://docs.datadoghq.com/developers/dogstatsd/datagram_shell/?tab=metrics. More...
 
 renderStatsD (Sample $sample)
 Renders metrics in StatsD format. More...
 

Detailed Description

Definition at line 37 of file MetricUtils.php.

Member Function Documentation

◆ addSample()

Wikimedia\Metrics\MetricUtils::addSample ( Sample  $sample)

Adds a sample to cache.

Parameters
Sample$sample

Definition at line 104 of file MetricUtils.php.

◆ getFilteredSamples()

Wikimedia\Metrics\MetricUtils::getFilteredSamples ( )
private

Get set of samples filtered according to configured sampleRate.

Returns
array

Definition at line 147 of file MetricUtils.php.

References Wikimedia\Metrics\MetricUtils\$samples.

Referenced by Wikimedia\Metrics\MetricUtils\render().

◆ render()

Wikimedia\Metrics\MetricUtils::render ( )

◆ renderDogStatsD()

◆ renderStatsD()

Wikimedia\Metrics\MetricUtils::renderStatsD ( Sample  $sample)
private

◆ setTypeIndicator()

Wikimedia\Metrics\MetricUtils::setTypeIndicator ( string  $typeIndicator)

Sets the StatsD protocol type indicator.

Parameters
string$typeIndicator

Definition at line 96 of file MetricUtils.php.

References Wikimedia\Metrics\MetricUtils\$typeIndicator.

Referenced by Wikimedia\Metrics\CounterMetric\__construct(), Wikimedia\Metrics\GaugeMetric\__construct(), and Wikimedia\Metrics\TimingMetric\__construct().

◆ validateConfig()

Wikimedia\Metrics\MetricUtils::validateConfig (   $config)
Parameters
array$configassociative array:
  • prefix: (string) The prefix prepended to the start of the metric name.
  • name: (string) The metric name
  • extension: (string) The extension generating the metric
  • labels: (array) List of metric dimensional instantiations for filters and aggregations
  • sampleRate: (float) Optional sampling rate to apply
  • format: (string) The expected output format – one of MetricsFactory::SUPPORTED_OUTPUT_FORMATS

Definition at line 75 of file MetricUtils.php.

Referenced by Wikimedia\Metrics\CounterMetric\__construct(), Wikimedia\Metrics\GaugeMetric\__construct(), and Wikimedia\Metrics\TimingMetric\__construct().

◆ validateLabels()

Wikimedia\Metrics\MetricUtils::validateLabels ( array  $labels)
Parameters
array$labels
Exceptions
InvalidLabelsException

Definition at line 134 of file MetricUtils.php.

References Wikimedia\Metrics\MetricUtils\$labels.

Member Data Documentation

◆ $extension

string Wikimedia\Metrics\MetricUtils::$extension
protected

Definition at line 46 of file MetricUtils.php.

◆ $format

string Wikimedia\Metrics\MetricUtils::$format
protected

Definition at line 49 of file MetricUtils.php.

◆ $labels

string [] Wikimedia\Metrics\MetricUtils::$labels
protected

◆ $name

string Wikimedia\Metrics\MetricUtils::$name
protected

Definition at line 52 of file MetricUtils.php.

◆ $prefix

string Wikimedia\Metrics\MetricUtils::$prefix
protected
Initial value:
=
private const RE_VALID_NAME_AND_LABEL_NAME '/^[a-zA-Z_][a-zA-Z0-9_]*$/'

Definition at line 43 of file MetricUtils.php.

◆ $sampleRate

float Wikimedia\Metrics\MetricUtils::$sampleRate
protected

◆ $samples

Sample [] Wikimedia\Metrics\MetricUtils::$samples = []
protected

Definition at line 61 of file MetricUtils.php.

Referenced by Wikimedia\Metrics\MetricUtils\getFilteredSamples().

◆ $typeIndicator

string Wikimedia\Metrics\MetricUtils::$typeIndicator
protected

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