示例#1
0
 def __init__(self, conn, conf, msg):
     super(SummarySample, self).__init__(conn, conf, SummaryService, "summary", msg)
     self.summary_id = msg.summary_id
     self.labels = msg.labels
     self.content = self._maybe_deserialize_datatype(msg.content)
     self.created_at = time_utils.datetime_from_millis(msg.created_at_millis)
     self.time_window_start_at = time_utils.datetime_from_millis(
         msg.time_window_start_at_millis
     )
     self.time_window_end_at = time_utils.datetime_from_millis(
         msg.time_window_end_at_millis
     )
示例#2
0
 def __init__(self, conn, conf, msg):
     super(SummarySample, self).__init__(conn, conf, SummaryService,
                                         "summary", msg)
     # TODO: convert these public attributes to read-only properties
     self.summary_id = msg.summary_id
     self.labels = msg.labels
     self.content = self._maybe_deserialize_datatype(msg.content)
     self.created_at = time_utils.datetime_from_millis(
         msg.created_at_millis)
     self.time_window_start_at = time_utils.datetime_from_millis(
         msg.time_window_start_at_millis)
     self.time_window_end_at = time_utils.datetime_from_millis(
         msg.time_window_end_at_millis)
示例#3
0
 def __init__(self, msg):
     self._event_time = time_utils.datetime_from_millis(
         msg.event_time_millis)
     self._status = status_module._AlertStatus._from_proto(
         msg.status,
         msg.violating_summary_sample_ids,
     )
示例#4
0
    def starting_from(self):
        self._refresh_cache()

        millis = self._msg.sample_find_base.filter.time_window_start_at_millis
        if not millis:
            return None
        return time_utils.datetime_from_millis(millis)
示例#5
0
    def last_evaluated_at(self):
        self._refresh_cache()

        millis = self._msg.last_evaluated_at_millis
        if not millis:
            return None
        return time_utils.datetime_from_millis(millis)
示例#6
0
    def _from_proto_request(cls, msg):
        # set attrs after creation to bypass conversion logic in __init__()
        obj = cls()
        obj._find_summaries = msg.filter.find_summaries
        obj._sample_ids = msg.filter.sample_ids
        obj._labels = msg.filter.labels
        obj._time_window_start = time_utils.datetime_from_millis(
            msg.filter.time_window_start_at_millis)
        obj._time_window_end = time_utils.datetime_from_millis(
            msg.filter.time_window_end_at_millis)
        obj._created_after = time_utils.datetime_from_millis(
            msg.filter.created_at_after_millis)
        obj._page_number = msg.page_number
        obj._page_limit = pagination_utils.page_limit_from_proto(
            msg.page_limit)

        return obj
示例#7
0
    def test_set_status(self, summary, summary_sample):
        name = _utils.generate_default_name()
        alerter = FixedAlerter(comparison.GreaterThan(0.7))

        alert = summary.alerts.create(name, alerter)
        assert alert.status == Ok()
        assert alert.last_evaluated_at is None

        alert.set_status(Alerting([summary_sample]))
        assert alert.status == Alerting([summary_sample])
        assert alert.last_evaluated_at == time_utils.datetime_from_millis(
            alert._msg.last_evaluated_at_millis)

        alert.set_status(Ok())
        assert alert.status == Ok()
示例#8
0
    def updated_at(self):
        self._refresh_cache()

        return time_utils.datetime_from_millis(self._msg.updated_at_millis)