Beispiel #1
0
 def _publish_metrics(self):
     msg = MetricMessage()
     for metric in self._metrics:
         msg.append((metric.name, metric.aggs, metric.poll()))
     self.publish_message(msg)
     if self._on_publish is not None:
         self._on_publish(self)
Beispiel #2
0
 def _publish_metrics(self):
     msg = MetricMessage()
     for metric in self._metrics:
         msg.append((metric.name, metric.aggs, metric.poll()))
     self.publish_message(msg)
     if self._on_publish is not None:
         self._on_publish(self)
Beispiel #3
0
    def publish_metric(self, metric_name, aggregates, values):
        timestamp_buckets = {}
        for timestamp, value in values:
            ts_key = int(timestamp) / self.bucket_size
            ts_bucket = timestamp_buckets.get(ts_key)
            if ts_bucket is None:
                ts_bucket = timestamp_buckets[ts_key] = []
            ts_bucket.append((timestamp, value))

        for ts_key, ts_bucket in timestamp_buckets.iteritems():
            bucket = self.find_bucket(metric_name, ts_key)
            routing_key = self.ROUTING_KEY_TEMPLATE % bucket
            msg = MetricMessage()
            msg.append((metric_name, aggregates, ts_bucket))
            self.publish_message(msg, routing_key=routing_key)
Beispiel #4
0
    def publish_metric(self, metric_name, aggregates, values):
        timestamp_buckets = {}
        for timestamp, value in values:
            ts_key = int(timestamp) / self.bucket_size
            ts_bucket = timestamp_buckets.get(ts_key)
            if ts_bucket is None:
                ts_bucket = timestamp_buckets[ts_key] = []
            ts_bucket.append((timestamp, value))

        for ts_key, ts_bucket in timestamp_buckets.iteritems():
            bucket = self.find_bucket(metric_name, ts_key)
            routing_key = self.ROUTING_KEY_TEMPLATE % bucket
            msg = MetricMessage()
            msg.append((metric_name, aggregates, ts_bucket))
            self.publish_message(msg, routing_key=routing_key)
Beispiel #5
0
 def publish_aggregate(self, metric_name, timestamp, value):
     # TODO: perhaps change interface to publish multiple metrics?
     msg = MetricMessage()
     msg.append((metric_name, (), [(timestamp, value)]))
     self.publish_message(msg)
Beispiel #6
0
 def publish_aggregate(self, metric_name, timestamp, value):
     # TODO: perhaps change interface to publish multiple metrics?
     msg = MetricMessage()
     msg.append((metric_name, (), [(timestamp, value)]))
     self.publish_message(msg)