Log timing information

@param string $stat The metric to in log timing info for.
@param float $time The ellapsed time (ms) to log
@param float|1.0 $sampleRate the rate (0-1) for sampling.
@param array|null $tags

@return Observable
176546
public function timing($stat, $time, $sampleRate = 1, array $tags = null)
    {
        return $this->send(array($stat => "$time|ms"), $sampleRate, $tags);
    }
98382
public function getFormattedTime(
        $time,
        $precision = 0,
        $floatingPrecision = 3,
        $showUnit = true
    ) {

        $test = is_int(
                $precision
            ) && $precision >= 0 && $precision <= 2 &&
            is_float($time) &&
            is_int($floatingPrecision) && $floatingPrecision >= 0 &&
            is_bool($showUnit);

        if ($test) {
            $duration = round($time * 10 * ($precision * 3), $floatingPrecision);

            if ($showUnit) {
                switch ($precision) {
                    case 0 :
                        return $duration . ' s';
                    case 1 :
                        return $duration . ' ms';
                    case 2 :
                        return $duration . ' µs';
                    default :
                        return $duration . ' (no unit)';
                }
            } else {
                return $duration;
            }
        } else {
            return 'Can\'t return the render time';
        }
    }
356732
public function histogram($stat, $value, $sampleRate = 1, array $tags = null)
    {
        return $this->send(array($stat => "$value|h"), $sampleRate, $tags);
    }
1118454
public function counter($metric, $count = 1, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        try {
            $this->sendMetric($this->metricFactory->counter($metric, $count, $tags, $sampleRate));
        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
101402
public function time($metric, $func, array $tags = array())
    {
        $timer_start = microtime(true);
        $func();
        $timer_end = microtime(true);
        $time = round(($timer_end - $timer_start) * 1000, 4);
        return $this->timing($metric, $time, $tags);
    }
51069
public function endTiming($metric, array $tags = array())
    {
        $timer_start = $this->metricTiming[$metric];
        $timer_end = microtime(true);
        $time = round(($timer_end - $timer_start) * 1000, 4);
        return $this->timing($metric, $time, $tags);
    }
883020
public function end($metric, array $tags = array())
    {
        try {
            if (!isset($this->timers[$metric])) {
                throw new \RuntimeException("Timer for metric $metric was not started");
            }

            if (!empty($tags)) {
                $this->timers[$metric]->setTags(array_merge($this->timers[$metric]->getTags(), $tags));
            }

            $this->sendMetric($this->timers[$metric]->end());
            unset ($this->timers[$metric]);

        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
1215853
public function times($times = null)
    {
        // API compat with mockery
        if ($this->atLeastWasCalled && $times !== null) {
            $this->atLeastWasCalled = false;
            $this->atLeast($times);
        } elseif ($times !== null) {
            if ($times === 0) {
                $this->never();
            } else {
                // normal operation
                $count = 0;
                $this->expectation->setPostPerformCallback(function() use (&$count, $times){
                    $count++;
                    $this->commentBuilder->incrementCallCount();
                    if ($count === $times) {
                        $this->expectation->setSatisfied(true);
                        $this->expectation->setPerformCallback(function($name, $args) use ($times) {
                            $message = "Unexpected call to {$this->methodName}";

                            if (count($args)) {
                                $message .= " with " . Util::printArray($args);
                            }

                            $message .= " - already called $times times";

                            throw new UnexpectedCallException($message);
                        });
                    }
                });

                $this->commentBuilder->setTimes($times);
                $this->commentBuilder->setAtLeast(false);
            }
        }
        
        return $this;
    }
666742
public function gauge($metric, $level, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        try {
            $this->sendMetric($this->metricFactory->gauge($metric, $level, $tags, $sampleRate));
        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
1279939
public static function parseFromLocale($time, $locale, $tz = null)
    {
        return static::rawParse(static::translateTimeString($time, $locale, 'en'), $tz);
    }
576053
public function gauge($metric, $level, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        return new Gauge($this->prefix($metric), $level, array_merge($this->defaultTags, $tags), $sampleRate);
    }
159618
protected function log($time)
	{
		// Build the actual query
		$query = $this->toString();

		Event::trigger('database_query', [
			'query' => $query,
			'time'  => $time
		]);

		// Add it to the internal logs
		$this->log[] = $query;
		$this->count++;
		$this->timer += $time;
	}
196681
protected function stat($time, $name)
    {
        $stats = $this->get('stats', ['interval' => $time], (string) $time);

        return array_get($stats, 'response.result.objs.0.'.$name);
    }
850587
public function onPodiumStart($time)
    {
        $jbMap = $this->jukeboxService->getFirst();
        if ($jbMap) {
            $length = count($this->jukeboxService->getMapQueue());
            $this->chatNotification->sendMessage('expansion_jukebox.chat.nextjbmap', null, [
                "%mapname%" => $jbMap->getMap()->name,
                "%mapauthor%" => $jbMap->getMap()->author,
                "%nickname%" => $jbMap->getPlayer()->getNickName(),
                "%length%" => $length,
            ]);
        } else {
            $map = $this->mapStorage->getNextMap();
            $this->chatNotification->sendMessage('expansion_jukebox.chat.nextmap', null, [
                "%name%" => $map->name,
                "%author%" => $map->author,
            ]);
        }
    }
621338
public static function info(String $message, String $time = NULL)
	{
		return 	self::report(__FUNCTION__, $message, NULL, $time);
	}
372430
public static function alert(String $message, String $time = NULL)
	{
		return self::report(__FUNCTION__, $message, NULL, $time);
	}
212386
public static function error(String $message, String $time = NULL)
	{
		return self::report(__FUNCTION__, $message, NULL, $time);
	}