MediaWiki master
Wikimedia\Stats\Metrics\GaugeMetric Class Reference

Gauge Metric Implementation. More...

Inherits Wikimedia\Stats\Metrics\MetricInterface.

Collaboration diagram for Wikimedia\Stats\Metrics\GaugeMetric:

Public Member Functions

 __construct ( $baseMetric, $logger)
 
 copyToStatsdAt ( $statsdNamespaces)
 Copies metric operation to StatsD at provided namespace.Takes a namespace or multiple namespaces.
Parameters
string | string[]$statsdNamespaces
Returns
CounterMetric|GaugeMetric|TimingMetric|NullMetric

 
 fresh ()
 Returns metric with cleared labels.
Returns
CounterMetric|GaugeMetric|TimingMetric|NullMetric

 
 getComponent ()
 
Returns
string

 
 getLabelKeys ()
 Returns the list of defined label keys.
Returns
string[]

 
 getName ()
 
Returns
string

 
 getSampleCount ()
 Returns a count of samples recorded by the metric.
Returns
int

 
 getSampleRate ()
 
Returns
float

 
 getSamples ()
 Returns subset of samples corresponding to sample rate setting.
Returns
Sample[]

 
 getTypeIndicator ()
 
Returns
string

 
 set (float $value)
 Sets metric to value.
 
 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
CounterMetric|GaugeMetric|TimingMetric|NullMetric

 
 setSampleRate (float $sampleRate)
 Sets sample rate on a new metric instance.
Parameters
float$sampleRate
Returns
CounterMetric|GaugeMetric|TimingMetric|NullMetric

 
- Public Member Functions inherited from Wikimedia\Stats\Metrics\MetricInterface
 __construct (BaseMetricInterface $baseMetric, LoggerInterface $logger)
 

Detailed Description

Gauge Metric Implementation.

Gauge Metrics can be set to any numeric value and are identified by type "g".

Author
Cole White
Since
1.38

Definition at line 37 of file GaugeMetric.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Stats\Metrics\GaugeMetric::__construct ( $baseMetric,
$logger )

Definition at line 55 of file GaugeMetric.php.

Member Function Documentation

◆ copyToStatsdAt()

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

Copies metric operation to StatsD at provided namespace.Takes a namespace or multiple namespaces.

Parameters
string | string[]$statsdNamespaces
Returns
CounterMetric|GaugeMetric|TimingMetric|NullMetric

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 139 of file GaugeMetric.php.

◆ fresh()

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

Returns metric with cleared labels.

Returns
CounterMetric|GaugeMetric|TimingMetric|NullMetric

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 151 of file GaugeMetric.php.

◆ getComponent()

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

Returns
string

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 85 of file GaugeMetric.php.

◆ getLabelKeys()

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

Returns the list of defined label keys.

Returns
string[]

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 122 of file GaugeMetric.php.

◆ getName()

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

Returns
string

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 80 of file GaugeMetric.php.

◆ getSampleCount()

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

Returns a count of samples recorded by the metric.

Returns
int

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 100 of file GaugeMetric.php.

◆ getSampleRate()

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

Returns
float

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 105 of file GaugeMetric.php.

◆ getSamples()

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

Returns subset of samples corresponding to sample rate setting.

Returns
Sample[]

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 95 of file GaugeMetric.php.

◆ getTypeIndicator()

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

Returns
string

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 90 of file GaugeMetric.php.

◆ set()

Wikimedia\Stats\Metrics\GaugeMetric::set ( float $value)

Sets metric to value.

Parameters
float$value
Returns
void

Definition at line 66 of file GaugeMetric.php.

◆ setLabel()

Wikimedia\Stats\Metrics\GaugeMetric::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
CounterMetric|GaugeMetric|TimingMetric|NullMetric

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 127 of file GaugeMetric.php.

◆ setSampleRate()

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

Sets sample rate on a new metric instance.

Parameters
float$sampleRate
Returns
CounterMetric|GaugeMetric|TimingMetric|NullMetric

Implements Wikimedia\Stats\Metrics\MetricInterface.

Definition at line 110 of file GaugeMetric.php.


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