MediaWiki master
Wikimedia\Stats\Metrics\BaseMetricInterface Interface Reference

Base Metric Interface. More...

Inherited by Wikimedia\Stats\Metrics\BaseMetric.

Public Member Functions

 __construct (string $component, string $name)
 
 addLabel (string $key, string $value)
 Add a label with key => value.
 
 addSample (Sample $sample)
 Records a Metric Sample.
 
 clearLabels ()
 Clears the working labels.
 
 getComponent ()
 Returns the Metric Component.
 
 getLabelKeys ()
 Returns array of label keys.
 
 getLabelValues ()
 Returns an array of label values in the order of label keys.
 
 getName ()
 Returns the Metric Name.
 
 getSampleCount ()
 Returns a count of samples recorded by the metric.
 
 getSampleRate ()
 Returns the configured sample rate.
 
 getSamples ()
 Returns subset of samples corresponding to sample rate setting.
 
 getStatsdDataFactory ()
 Gets StatsD Data Factory instance or null.
 
 getStatsdNamespaces ()
 Returns the configured legacy StatsD namespaces.
 
 setSampleRate (float $sampleRate)
 Sets the sample rate.
 
 setStatsdNamespaces ( $statsdNamespaces)
 Validates and sets legacy StatsD namespaces.
 
 withStatsdDataFactory (IBufferingStatsdDataFactory $statsdDataFactory)
 StatsD Data Factory instance to copy metrics to.
 

Detailed Description

Base Metric Interface.

Interface for defining a Base Metric.

Author
Cole White
Since
1.41

Definition at line 35 of file BaseMetricInterface.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Stats\Metrics\BaseMetricInterface::__construct ( string $component,
string $name )
Parameters
string$componentThe component this metric will track.
string$nameThe Metric Name.

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

Member Function Documentation

◆ addLabel()

Wikimedia\Stats\Metrics\BaseMetricInterface::addLabel ( string $key,
string $value )

Add a label with key => value.

Note that the order in which labels are added is significant for StatsD output.

Example:

$statsFactory->withComponent( 'demo' )
->getCounter( 'testMetric_total' )
->setLabel( 'first', 'foo' )
->setLabel( 'second', 'bar' )
->setLabel( 'third', 'baz' )
->increment();

statsd: "mediawiki.demo.testMetric_total.foo.bar.baz" prometheus: "mediawiki_demo_testMetric_total{first='foo',second='bar',third='baz'}

Parameters
string$key
string$value
Returns
void

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ addSample()

Wikimedia\Stats\Metrics\BaseMetricInterface::addSample ( Sample $sample)

Records a Metric Sample.

Parameters
Sample$sample
Returns
void

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ clearLabels()

Wikimedia\Stats\Metrics\BaseMetricInterface::clearLabels ( )

Clears the working labels.

Returns
void

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getComponent()

Wikimedia\Stats\Metrics\BaseMetricInterface::getComponent ( )

Returns the Metric Component.

Returns
string

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getLabelKeys()

Wikimedia\Stats\Metrics\BaseMetricInterface::getLabelKeys ( )

Returns array of label keys.

Returns
string[]

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getLabelValues()

Wikimedia\Stats\Metrics\BaseMetricInterface::getLabelValues ( )

Returns an array of label values in the order of label keys.

Returns
string[]

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getName()

Wikimedia\Stats\Metrics\BaseMetricInterface::getName ( )

Returns the Metric Name.

Returns
string

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getSampleCount()

Wikimedia\Stats\Metrics\BaseMetricInterface::getSampleCount ( )

Returns a count of samples recorded by the metric.

Returns
int

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getSampleRate()

Wikimedia\Stats\Metrics\BaseMetricInterface::getSampleRate ( )

Returns the configured sample rate.

Returns
float

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getSamples()

Wikimedia\Stats\Metrics\BaseMetricInterface::getSamples ( )

Returns subset of samples corresponding to sample rate setting.

Returns
Sample[]

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getStatsdDataFactory()

Wikimedia\Stats\Metrics\BaseMetricInterface::getStatsdDataFactory ( )

Gets StatsD Data Factory instance or null.

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ getStatsdNamespaces()

Wikimedia\Stats\Metrics\BaseMetricInterface::getStatsdNamespaces ( )

Returns the configured legacy StatsD namespaces.

Returns
string[]

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ setSampleRate()

Wikimedia\Stats\Metrics\BaseMetricInterface::setSampleRate ( float $sampleRate)

Sets the sample rate.

Parameters
float$sampleRate

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ setStatsdNamespaces()

Wikimedia\Stats\Metrics\BaseMetricInterface::setStatsdNamespaces ( $statsdNamespaces)

Validates and sets legacy StatsD namespaces.

Parameters
string | string[]$statsdNamespaces
Returns
void

Implemented in Wikimedia\Stats\Metrics\BaseMetric.

◆ withStatsdDataFactory()

Wikimedia\Stats\Metrics\BaseMetricInterface::withStatsdDataFactory ( IBufferingStatsdDataFactory $statsdDataFactory)

StatsD Data Factory instance to copy metrics to.

Parameters
IBufferingStatsdDataFactory$statsdDataFactory
Returns
BaseMetricInterface

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