MediaWiki master
|
Timing Metric Implementation. More...
Inherits Wikimedia\Stats\Metrics\MetricInterface.
Public Member Functions | |
getTypeIndicator () | |
| |
observe (float $milliseconds) | |
Record a previously calculated observation in milliseconds. | |
observeNanoseconds (float $nanoseconds) | |
Record a previously calculated observation in nanoseconds. | |
observeSeconds (float $seconds) | |
Record a previously calculated observation in seconds. | |
start () | |
Start the timer. | |
stop () | |
Stop the running timer. | |
![]() | |
__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. | |
isHistogram () | |
Indicates the metric instance is used in a Histogram. | |
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. | |
Timing Metric Implementation.
Timing metrics track duration data which can be broken into histograms. They are identified by type "ms".
Definition at line 36 of file TimingMetric.php.
Wikimedia\Stats\Metrics\TimingMetric::getTypeIndicator | ( | ) |
Implements Wikimedia\Stats\Metrics\MetricInterface.
Definition at line 155 of file TimingMetric.php.
Wikimedia\Stats\Metrics\TimingMetric::observe | ( | float | $milliseconds | ) |
Record a previously calculated observation in milliseconds.
NOTE: You MUST pass values converted to milliseconds.
This method is discouraged in new code, because PHP does not measure time in milliseconds. It will be less error-prone if you use start() and stop(), or pass values from hrtime() directly to observeNanoseconds() without manual multiplication to another unit.
float | $milliseconds |
Definition at line 137 of file TimingMetric.php.
Wikimedia\Stats\Metrics\TimingMetric::observeNanoseconds | ( | float | $nanoseconds | ) |
Record a previously calculated observation in nanoseconds.
Example:
float | $nanoseconds |
Definition at line 95 of file TimingMetric.php.
Wikimedia\Stats\Metrics\TimingMetric::observeSeconds | ( | float | $seconds | ) |
Record a previously calculated observation in seconds.
This method is provided for tracking externally-generated values, timestamp deltas, and situations where the expected input value is the expected Prometheus graphed value.
Performance measurements in process should be done with hrtime() and observeNanoseconds() to ensure monotonic time is used and not wall-clock time.
Example:
float | $seconds |
Definition at line 120 of file TimingMetric.php.
Wikimedia\Stats\Metrics\TimingMetric::start | ( | ) |
Start the timer.
Example:
Definition at line 63 of file TimingMetric.php.
Wikimedia\Stats\Metrics\TimingMetric::stop | ( | ) |
Stop the running timer.
Definition at line 71 of file TimingMetric.php.