Sends an histogram

@param string $metric     Metric name
@param int    $duration   Duration of the metric in milliseconds
@param array  $tags       Metric tags
@param int    $sampleRate Sample rate for the metric

@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;
    }
1277915
public function store(Metric $metric)
    {
        try {
            $metricPoint = execute(new CreateMetricPointCommand(
                $metric,
                Binput::get('value'),
                Binput::get('timestamp')
            ));
        } catch (QueryException $e) {
            throw new BadRequestHttpException();
        }

        return $this->item($metricPoint);
    }
306024
protected function importMetric($now, $metric, $config, $rp) {
        $offset = 0;
        $limit = 100;
        while (true) {          
            $query = sprintf($config["mysql"]["query"][$rp], $limit, $offset);
            $rows = $this->mapper->getRows($query);

            if (count($rows) <= 0) {
                break;
            }

            foreach ($rows as $row) {
                $tags = array_intersect_key($row, $config["influx"]["tags"]);
                if(!$this->areTagsValid($tags) || !$this->isUtcValid($tags["utc"], $now, $rp)) {
                    print("Utc[" . $tags["utc"] . "] is not valid, now[$now], rp[$rp]\n");
                } else {
                    $value = $tags["value"];
                    $utc = $tags["utc"];
                    unset($tags["value"]);
                    unset($tags["utc"]);
                
                    $this->analytics->save($metric, $tags, intval($value), $utc, $rp); 
                }
            }
            $offset += $limit;
            usleep(300000);
        }
    }
842781
public function sendShowSlateChannelOperation($channel, $duration, $assetId)
    {
        $channelId = Utilities::getEntityId(
            $channel,
            'WindowsAzure\MediaServices\Models\Channel'
        );
        $headers = [
            Resources::CONTENT_TYPE => Resources::JSON_CONTENT_TYPE,
        ];
        $body = json_encode([
            'duration' => $duration,
            'assetId' => $assetId,
        ]);

        return $this->_sendOperation(
            $body,
            "Channels('{$channelId}')/ShowSlate",
            Resources::HTTP_POST,
            Resources::STATUS_ACCEPTED,
            $headers);
    }
1015844
public function writeDuration(QtiDuration $duration)
    {
        try {
            $this->writeString($duration->__toString());
        } catch (BinaryStreamAccessException $e) {
            $msg = "An error occured while writing a duration.";
            throw new QtiBinaryStreamAccessException($msg, $this, QtiBinaryStreamAccessException::DURATION, $e);
        }
    }
528921
def submit_as_gauge_and_monotonic_count(self, metric_suffix, metric, scraper_config):
        
        metric_name = scraper_config['namespace'] + metric_suffix
        for sample in metric.samples:
            # Explicit shallow copy of the instance tags
            _tags = list(scraper_config['custom_tags'])

            for label_name, label_value in iteritems(sample[self.SAMPLE_LABELS]):
                _tags.append('{}:{}'.format(label_name, label_value))
            # submit raw metric
            self.gauge(metric_name, sample[self.SAMPLE_VALUE], _tags)
            # submit rate metric
            self.monotonic_count(metric_name + '.count', sample[self.SAMPLE_VALUE], _tags)
1218265
public function increment($stats, $sampleRate = 1, array $tags = null)
    {
        return $this->updateStats($stats, 1, $sampleRate, $tags);
    }
409701
public function update(Metric $metric)
    {
        try {
            $metric = execute(new UpdateMetricCommand(
                $metric,
                Binput::get('name'),
                Binput::get('suffix'),
                Binput::get('description'),
                Binput::get('default_value'),
                Binput::get('calc_type'),
                Binput::get('display_chart'),
                Binput::get('places'),
                Binput::get('default_view', Binput::get('view')),
                Binput::get('threshold'),
                Binput::get('order'),
                Binput::get('visible')
            ));
        } catch (QueryException $e) {
            throw new BadRequestHttpException();
        }

        return $this->item($metric);
    }
1321216
public function decrement($stats, $sampleRate = 1, array $tags = null)
    {
        return $this->updateStats($stats, -1, $sampleRate, $tags);
    }
449713
public function plusDuration(Duration $duration) : ZonedDateTime
    {
        return ZonedDateTime::ofInstant($this->instant->plus($duration), $this->timeZone);
    }
471818
public function setMetric($metric)
  {
    if (ThrottlerHelper::validateMetric($metric, self::$timeFactor)
        && !$this->isActive())
    {
      $this->metric = strtolower($metric);
      return true;
    }
    return false;
  }
705413
public function getSum($metric, $tags, $endDt = null) {
        if (null == $metric) {
            return 0;
        }
        
        $min = intval(date('i'));
        $minutes = $min > 45 ? 45 : ( $min > 30 ? 30 : ( $min > 15 ? 15 : '00') );       
        $lastHourDt = date("Y-m-d") . "T" . date('H') . ":$minutes:00Z";
  
        $where = [];
        
        if (!isset($endDt)) {
            $endDt = '2100-01-01T00:00:00Z';
        }
        
        if (strtotime($endDt) < strtotime($lastHourDt)) {
           return 0;
        }
        
        $where[] = "time >= '" . $lastHourDt . "' AND time <= '" . $endDt . "'";
        
        foreach ($tags as $key => $val) {
            $where[] = "$key = '" . $val . "'";
        }

        $points = $this->db->getQueryBuilder()
                ->from($metric)
                ->where($where)
                ->sum('value')
                ->getResultSet()
                ->getPoints();
        
        return isset($points[0]) && isset($points[0]["sum"]) ? $points[0]["sum"] : 0;
    }
1128078
public function assign($media, $duration, $playlistId)
    {
        $this->playlistId = $playlistId;
        $this->media = $media;
        $this->getLogger()->info('Assigning Media To Playlist ' . $this->playlistId);
        $response = $this->doPost('/playlist/library/assign/' . $playlistId, [
        	'media' => $media,
            'duration' => $duration
        	]);

        // Parse response
        //  set properties
        $this->playlistId = $response['playlistId'];

        $this->getLogger()->debug('Creating child object Widgets and linking it to parent Playlist');
        // Set widgets property (with XiboWidget objects)
        foreach ($response['widgets'] as $widget) {
            $this->widgets[] = (new XiboWidget($this->getEntityProvider()))->hydrate($widget);
        }

        return $this;
    }
170286
public function set($metric, $uniqueValue, array $tags =array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        return new Set($this->prefix($metric), $uniqueValue, array_merge($this->defaultTags, $tags), $sampleRate);
    }
1330351
public function Tag($tag, $instance, array $options = null)
    {
        //========================
        // Determine Handler
        //========================
        if(isset($options['cacheHandler'])) {
            if (isset($this->cacheHandlers[$options['cacheHandler']]))
            {
                $handler = $this->cacheHandlers[$options['cacheHandler']];
            } else {
                trigger_error("KeyRing Tag requested but that cache handler was not provided during construction of keyring", E_USER_ERROR);
            }
        } else {
            $handler = $this->cacheHandlers[$this->defaultCacheHandler];
        }
        
        //==================================
        // Check if Tag Version Specified
        //===================================
        $version = isset($options['version']) ? $options['version'] : null;                
        
        //==================================
        // Check if Prefix Specified
        //===================================
        $prefix = isset($options['prefix']) ? $options['prefix'] : $this->defaultPrefix;                
        
        // Determine Type
        if(isset($options['type'])) {
            switch(strtolower($options['type']))
            {
                case 'standard':                   
                    $tag = new FragmentedKeys\Tag\Standard($tag, $instance, $version, $handler, $prefix);
                    break;                
                case 'constant':
                    $tag = new FragmentedKeys\Tag\Constant($tag, $instance, $version, $handler, $prefix);
                    break;
            }
        }        
        return $tag;         
    }
1191083
public function performQuery(Period $period, string $metrics, array $others = [])
    {
        return $this->client->performQuery(
            $this->viewId,
            $period->startDate,
            $period->endDate,
            $metrics,
            $others
        );
    }
805983
static function timer_tags_merge($timer, $tags)
    {
        if (isset(self::$timers[$timer]))
        {
            self::$timers[$timer]["tags"] = array_merge(self::$timers[$timer]["tags"], $tags);
            return true;
        }
        return false;
    }