Metrics::push

@param Metric $metric
489728
public function push($metric)
    {
        $metric->stop();

        if ( ! $this->isEmpty()) {
            $metric->start($this->top()->endTime, $this->top()->endMemory);
        } elseif (defined('STARTUP_MEMORY')) {
            $metric->start(STARTUP_TIME, STARTUP_MEMORY);
        }

        parent::push($metric);
    }
678663
def add_metrics(self, metrics: Iterable[float]) -> None:
        
        for metric in metrics:
            self.add_metric(metric)
371452
public function index(Metric $metric, MetricPoint $metricPoint)
    {
        $points = $metric->points()->paginate(Binput::get('per_page', 20));

        return $this->paginator($points, Request::instance());
    }
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;
    }
320660
public function push(Period $interval, Period ...$intervals): void
    {
        $this->intervals = array_merge($this->intervals, [$interval], $intervals);
    }
78085
def add_metric(self, metric: float) -> None:
        
        new_best = ((self._best_so_far is None) or
                    (self._should_decrease and metric < self._best_so_far) or
                    (not self._should_decrease and metric > self._best_so_far))

        if new_best:
            self.best_epoch = self._epoch_number
            self._is_best_so_far = True
            self._best_so_far = metric
            self._epochs_with_no_improvement = 0
        else:
            self._is_best_so_far = False
            self._epochs_with_no_improvement += 1
        self._epoch_number += 1
645278
public function queuePush(Job $job)
    {
        if ($this->isSingle()) {
            $queue_config = $this->getQueueConfig();
            if (isset($queue_config['driver'])) {
                /** @var BaseQueue $driver */
                $driver = $queue_config['driver'];
                $driver::component()->push($job);
            }
        }
    }
49644
protected function _renderCoverage($metrics)
    {
        $stats = $metrics->data();
        foreach ($stats['files'] as $file) {
            $this->write("File: {$file}" . "\n\n");

            $lines = file($file);

            $coverage = $this->_collector->export($file);

            if (isset($stats['line'])) {
                $start = $stats['line']['start'];
                $stop = $stats['line']['stop'];
            } else {
                $start = 0;
                $stop = count($lines) - 1;
            }

            for ($i = $start; $i <= $stop; $i++) {
                $value = isset($coverage[$i]) ? $coverage[$i] : null;
                $line = str_pad($i + 1, 6, ' ', STR_PAD_LEFT);
                $line .= ':' . str_pad($value, 6, ' ');
                $line .= $lines[$i];
                if ($value) {
                    $this->write($line, 'n;green');
                } elseif ($value === 0) {
                    $this->write($line, 'n;red');
                } else {
                    $this->write($line);
                }
            }
            $this->write("\n\n");
        }
    }
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;
    }
359035
public function histogram($metric, $duration, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        try {
            $this->sendMetric($this->metricFactory->histogram($metric, $duration, $tags, $sampleRate));
        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
471818
public function setMetric($metric)
  {
    if (ThrottlerHelper::validateMetric($metric, self::$timeFactor)
        && !$this->isActive())
    {
      $this->metric = strtolower($metric);
      return true;
    }
    return false;
  }
716745
function push($data)
    {
        return \Swoole::$php->redis($this->redis_factory_key)->lPush($this->key, serialize($data));
    }
1035492
protected function sendMetricThroughSenders(AbstractMetric $metric)
    {
        foreach ($this->metricSenders as $sender) {
            try {
                $sender->send($metric);
            } catch (\Exception $exception) {
                $this->logException($exception);
            }
        }
    }
4905
public function pushMessage($server, array $data)
    {
        $pusher = Pusher::make($data, $server);
        $pusher->push($this->payloadParser->encode(
            $pusher->getEvent(),
            $pusher->getMessage()
        ));
    }
1257335
protected function isMetricValid($metric) {
        if (!isset($metric) || !is_array($metric) 
                || !isset($metric["influx"]) || !isset($metric["influx"]["tags"]) 
                || !isset($metric["mysql"]) || !isset($metric["mysql"]["query"])) {
                    return false;
        }
        return true;
    }
606937
protected function push(IPoolResource $resource)
    {
        if(Coroutine::isIn())
        {
            $this->queue->push($resource);
        }
        else
        {
            go(function() use($resource){
                $this->queue->push($resource);
            });
        }
    }
1072862
public function listPointsLastHour(Metric $metric)
    {
        $dateTime = $this->dates->make();
        $pointKey = $dateTime->format('Y-m-d H:i');
        $nrOfMinutes = 61;
        $points = $this->repository->getPointsSinceMinutes($metric, $nrOfMinutes + $metric->threshold)->pluck('value', 'key')->take(-$nrOfMinutes);

        $timeframe = $nrOfMinutes;
        for ($i = 0; $i < $timeframe; $i++) {
            if (!$points->has($pointKey)) {
                if ($i >= $metric->threshold) {
                    $points->put($pointKey, $metric->default_value);
                } else {
                    // The point not found is still within the threshold, so it is ignored and
                    // the timeframe is shifted by one minute
                    $timeframe++;
                }
            }

            $pointKey = $dateTime->sub(new DateInterval('PT1M'))->format('Y-m-d H:i');
        }

        return $points->sortBy(function ($point, $key) {
            return $key;
        });
    }