コード例 #1
0
 def run(self):
     with session_scope() as db_session:
         update_last_accessed(db_session, endpoint_name=self._endpoint.name)
         add_request(db_session,
                     duration=self._duration,
                     endpoint_id=self._endpoint.id,
                     ip=self._ip)
コード例 #2
0
    def _on_thread_stopped(self):
        with session_scope() as db_session:
            update_last_accessed(db_session, endpoint_name=self._endpoint.name)
            request_id = add_request(db_session, duration=self._duration, endpoint_id=self._endpoint.id, ip=self._ip)
            self._lines_body = order_histogram(self._histogram.items())
            self.insert_lines_db(db_session, request_id)

        if self._outlier_profiler:
            self._outlier_profiler.add_outlier(request_id)
コード例 #3
0
 def test_update_last_accessed(self):
     """
         Test whether the function returns the right values.
     """
     import datetime
     time = datetime.datetime.now()
     from flask_monitoringdashboard.database.endpoint import update_last_accessed, get_last_accessed_times
     update_last_accessed(NAME, time)
     result = get_last_accessed_times()
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0].endpoint, NAME)
     self.assertEqual(result[0].last_accessed, time)
コード例 #4
0
 def test_update_last_accessed(self):
     """
         Test whether the function returns the right values.
     """
     import datetime
     time = datetime.datetime.utcnow()
     from flask_monitoringdashboard.database.endpoint import update_last_accessed, get_last_requested
     from flask_monitoringdashboard.database.count_group import get_value
     with session_scope() as db_session:
         update_last_accessed(db_session, NAME)
         result = get_value(get_last_requested(db_session), NAME)
         result_utc = to_utc_datetime(result)
         self.assertTrue((result_utc - time).seconds < 1)
コード例 #5
0
 def run(self):
     with session_scope() as db_session:
         update_last_accessed(db_session, endpoint_name=self._endpoint.name)
コード例 #6
0
 def wrapper(*args, **kwargs):
     update_last_accessed(endpoint=endpoint, value=datetime.datetime.now())
     return func(*args, **kwargs)