Ejemplo n.º 1
0
def decode_sent(data):
  pb_size = unpack(INT32_FORMAT, data[:INT32_SIZE])[0]
  data = data[INT32_SIZE:INT32_SIZE + pb_size]

  datapoints = []
  payload_pb = Payload.FromString(data)
  for metric_pb in payload_pb.metrics:
    for point_pb in metric_pb.points:
      datapoints.append(
        (metric_pb.metric, (point_pb.timestamp, point_pb.value)))
  return datapoints
Ejemplo n.º 2
0
    def stringReceived(self, data):
        try:
            payload_pb = Payload.FromString(data)
        except DecodeError:
            log.listener('invalid protobuf received from %s, ignoring' % self.peerName)
            return

        for metric_pb in payload_pb.metrics:
            for point_pb in metric_pb.points:
                self.metricReceived(
                    metric_pb.metric, (point_pb.timestamp, point_pb.value))