Slightly simplify SiteConfig metrics implementation & improve doc
Document that ::observeTiming takes an argument *in milliseconds* (not seconds). Use the new Metric::setLabels() method to simplify the implementation a bit as well. Change-Id: I374ff380466cfc5c12abb24793e8a4ed195db382
This commit is contained in:
parent
5b7fdde90d
commit
f3c5d81939
1 changed files with 7 additions and 11 deletions
|
|
@ -264,16 +264,14 @@ class SiteConfig extends ISiteConfig {
|
|||
/**
|
||||
* Record a timing metric
|
||||
* @param string $name
|
||||
* @param float $value
|
||||
* @param float $value A time value in milliseconds
|
||||
* @param array $labels
|
||||
* @return void
|
||||
*/
|
||||
public function observeTiming( string $name, float $value, array $labels ) {
|
||||
$metric = $this->prefixedStatsFactory()->getTiming( $name );
|
||||
foreach ( $labels as $labelKey => $labelValue ) {
|
||||
$metric->setLabel( $labelKey, $labelValue );
|
||||
}
|
||||
$metric->observe( $value );
|
||||
$this->prefixedStatsFactory()->getTiming( $name )
|
||||
->setLabels( $labels )
|
||||
->observe( $value );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -284,11 +282,9 @@ class SiteConfig extends ISiteConfig {
|
|||
* @return void
|
||||
*/
|
||||
public function incrementCounter( string $name, array $labels, float $amount = 1 ) {
|
||||
$metric = $this->prefixedStatsFactory()->getCounter( $name );
|
||||
foreach ( $labels as $labelKey => $labelValue ) {
|
||||
$metric->setLabel( $labelKey, $labelValue );
|
||||
}
|
||||
$metric->incrementBy( $amount );
|
||||
$this->prefixedStatsFactory()->getCounter( $name )
|
||||
->setLabels( $labels )
|
||||
->incrementBy( $amount );
|
||||
}
|
||||
|
||||
public function galleryOptions(): array {
|
||||
|
|
|
|||
Loading…
Reference in a new issue