MediaWiki master
|
Base Metric Implementation V1. More...
Inherits Wikimedia\Stats\Metrics\BaseMetricInterface.
Public Member Functions | |||||||
__construct (string $component, string $name) | |||||||
| |||||||
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.Static Labels always appear first.Example: $statsFactory->withComponent( 'demo' )
->addStaticLabel( 'first', 'foo' )
->addStaticLabel( 'second', 'bar' )
->getCounter( 'testMetric_total' )
->setLabel( 'third', 'baz' )
->increment();
statsd: "mediawiki.demo.testMetric_total.foo.bar.baz" prometheus: "mediawiki_demo_testMetric_total{first='foo',second='bar',third='baz'}
| |||||||
addSample (Sample $sample) | |||||||
Records a Metric Sample.
| |||||||
clearLabels () | |||||||
Clears the working labels.
| |||||||
getComponent () | |||||||
Returns the Metric Component.
| |||||||
getLabelKeys () | |||||||
getLabelValues () | |||||||
Combines the provided associative array of labels with the associative array of staticLabels and returns the values in the order of labelKeys. | |||||||
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.
| |||||||
withStaticLabels (array $labelKeys, array $labelValues) | |||||||
Configures the metric with static labels.
| |||||||
withStatsdDataFactory ( $statsdDataFactory) | |||||||
Public Member Functions inherited from Wikimedia\Stats\Metrics\BaseMetricInterface | |||||||
withStatsdDataFactory (IBufferingStatsdDataFactory $statsdDataFactory) | |||||||
StatsD Data Factory instance to copy metrics to. | |||||||
Base Metric Implementation V1.
Implements shared Metric functionality:
Definition at line 43 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::__construct | ( | string | $component, |
string | $name | ||
) |
string | $component | The component this metric will track. |
string | $name | The Metric Name. |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 73 of file BaseMetric.php.
References Wikimedia\Stats\StatsUtils\normalizeString().
Wikimedia\Stats\Metrics\BaseMetric::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.Static Labels always appear first.Example:
statsd: "mediawiki.demo.testMetric_total.foo.bar.baz" prometheus: "mediawiki_demo_testMetric_total{first='foo',second='bar',third='baz'}
string | $key | |
string | $value |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 121 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::addSample | ( | Sample | $sample | ) |
Records a Metric Sample.
Sample | $sample |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 79 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::clearLabels | ( | ) |
Clears the working labels.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 216 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getComponent | ( | ) |
Returns the Metric Component.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 221 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getLabelKeys | ( | ) |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 187 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getLabelValues | ( | ) |
Combines the provided associative array of labels with the associative array of staticLabels and returns the values in the order of labelKeys.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 198 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getName | ( | ) |
Returns the Metric Name.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 94 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getSampleCount | ( | ) |
Returns a count of samples recorded by the metric.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 109 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getSampleRate | ( | ) |
Returns the configured sample rate.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 99 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getSamples | ( | ) |
Returns subset of samples corresponding to sample rate setting.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 104 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getStatsdDataFactory | ( | ) |
Gets StatsD Data Factory instance or null.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 130 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::getStatsdNamespaces | ( | ) |
Returns the configured legacy StatsD namespaces.
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 159 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::setSampleRate | ( | float | $sampleRate | ) |
Sets the sample rate.
float | $sampleRate |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 84 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::setStatsdNamespaces | ( | $statsdNamespaces | ) |
Validates and sets legacy StatsD namespaces.
string | string[] | $statsdNamespaces |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 141 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::withStaticLabels | ( | array | $labelKeys, |
array | $labelValues | ||
) |
Configures the metric with static labels.
string[] | $labelKeys | |
string[] | $labelValues |
Implements Wikimedia\Stats\Metrics\BaseMetricInterface.
Definition at line 114 of file BaseMetric.php.
Wikimedia\Stats\Metrics\BaseMetric::withStatsdDataFactory | ( | $statsdDataFactory | ) |
Definition at line 135 of file BaseMetric.php.