|
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. | |
| Public Member Functions inherited from Wikimedia\Stats\Metrics\MetricInterface | |
| __construct (BaseMetricInterface $baseMetric, LoggerInterface $logger) | |
| copyToStatsdAt ( $statsdNamespaces) | |
| This function existed to support the Graphite->Prometheus transition and is no longer needed. | |
| 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 24 of file TimingMetric.php.
| Wikimedia\Stats\Metrics\TimingMetric::getTypeIndicator | ( | ) |
Implements Wikimedia\Stats\Metrics\MetricInterface.
Definition at line 164 of file TimingMetric.php.
References return.
| 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 150 of file TimingMetric.php.
| Wikimedia\Stats\Metrics\TimingMetric::observeNanoseconds | ( | float | $nanoseconds | ) |
Record a previously calculated observation in nanoseconds.
It is recommended to use TimingMetric::start() and RunningTimer::stop() instead.
Only measure latency yourself if you also need the duration value elsewhere.
Example:
| float | $nanoseconds |
Definition at line 106 of file TimingMetric.php.
| Wikimedia\Stats\Metrics\TimingMetric::observeSeconds | ( | float | $seconds | ) |
Record a previously calculated observation in seconds.
This method is provided to ease recording of externally-generated time values. For example, when a service returns a delta in seconds to you, and you are not measuring or multiplying this value yourself.
To instrument your own code, it is recommended to use TimingMetric::start() and RunningTimer::stop() instead. Or, if measuring by hand, use hrtime() with observeNanoseconds() to guarantee a monotonic clock and not a wall-clock.
Do not measure latency with time() or microtime(), per T245464.
NOTE: If you previously used observeSeconds to store non-time values in a histogram, such as kilobytes or other unrelated quantities, use StatsFactory::getHistogram instead (T348796, T364240, T383208).
| float | $seconds |
Definition at line 131 of file TimingMetric.php.
| Wikimedia\Stats\Metrics\TimingMetric::start | ( | ) |
Start the timer.
Example:
Example with an extra label informed by the work:
Definition at line 62 of file TimingMetric.php.
| Wikimedia\Stats\Metrics\TimingMetric::stop | ( | ) |
Stop the running timer.
Definition at line 72 of file TimingMetric.php.
References if.