9use Wikimedia\Timestamp\ConvertibleTimestamp;
23 private ?
float $startTime;
24 private array $workingLabels;
27 $this->startTime = $startTime;
28 $this->metric = $metric;
29 $this->workingLabels = $initialLabels;
38 public function setLabel(
string $key,
string $value ) {
39 $this->workingLabels[$key] = $value;
50 $this->workingLabels = $labels;
58 if ( $this->startTime ===
null ) {
60 "Stats: ({$this->metric->getName()}) cannot call stop() more than once on a RunningTimer.",
71 $this->metric = $this->metric->setLabels( $this->workingLabels );
72 $this->metric->observeNanoseconds( ConvertibleTimestamp::hrtime() - $this->startTime );
73 $this->startTime =
null;