MediaWiki master
Wikimedia\Stats\Metrics\MetricInterface Interface Reference

Metric Interface. More...

Inherited by Wikimedia\Stats\Metrics\CounterMetric, Wikimedia\Stats\Metrics\GaugeMetric, and Wikimedia\Stats\Metrics\TimingMetric.

Public Member Functions

 __construct (BaseMetricInterface $baseMetric, LoggerInterface $logger)
 
 copyToStatsdAt ( $statsdNamespaces)
 Copies metric operation to StatsD at provided namespace.
 
 fresh ()
 Returns metric with cleared labels.
 
 getComponent ()
 
 getLabelKeys ()
 Returns the list of defined label keys.
 
 getName ()
 
 getSampleCount ()
 Returns a count of samples recorded by the metric.
 
 getSampleRate ()
 
 getSamples ()
 Returns subset of samples corresponding to sample rate setting.
 
 getTypeIndicator ()
 
 setLabel (string $key, string $value)
 Adds a label $key with $value.
 
 setLabels (array $labels)
 Convenience function to set a number of labels at once.
 
 setSampleRate (float $sampleRate)
 Sets sample rate on a new metric instance.
 

Detailed Description

Metric Interface.

Author
Cole White
Since
1.41

Definition at line 31 of file MetricInterface.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Stats\Metrics\MetricInterface::__construct ( BaseMetricInterface $baseMetric,
LoggerInterface $logger )

Member Function Documentation

◆ copyToStatsdAt()

Wikimedia\Stats\Metrics\MetricInterface::copyToStatsdAt ( $statsdNamespaces)

Copies metric operation to StatsD at provided namespace.

Takes a namespace or multiple namespaces.

Parameters
string | string[]$statsdNamespaces
Returns
self|NullMetric

◆ fresh()

Wikimedia\Stats\Metrics\MetricInterface::fresh ( )

Returns metric with cleared labels.

Returns
self|NullMetric

◆ getComponent()

Wikimedia\Stats\Metrics\MetricInterface::getComponent ( )
Returns
string

◆ getLabelKeys()

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

Returns the list of defined label keys.

Returns
string[]

◆ getName()

Wikimedia\Stats\Metrics\MetricInterface::getName ( )
Returns
string

◆ getSampleCount()

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

Returns a count of samples recorded by the metric.

Returns
int

◆ getSampleRate()

Wikimedia\Stats\Metrics\MetricInterface::getSampleRate ( )
Returns
float

◆ getSamples()

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

Returns subset of samples corresponding to sample rate setting.

Returns
Sample[]

◆ getTypeIndicator()

Wikimedia\Stats\Metrics\MetricInterface::getTypeIndicator ( )

◆ setLabel()

Wikimedia\Stats\Metrics\MetricInterface::setLabel ( string $key,
string $value )

Adds a label $key with $value.

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

Example:

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

statsd: "mediawiki.testMetric_total.foo.bar" prometheus: "mediawiki_testMetric_total{ first='foo', second='bar' }

Parameters
string$key
string$value
Returns
self|NullMetric

◆ setLabels()

Wikimedia\Stats\Metrics\MetricInterface::setLabels ( array $labels)

Convenience function to set a number of labels at once.

See also
::setLabel
Parameters
array<string,string>$labels
Returns
self|NullMetric

◆ setSampleRate()

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

Sets sample rate on a new metric instance.

Parameters
float$sampleRate
Returns
self|NullMetric

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