def _persist_request_id(): g_object_attr = config.log_request_id setattr(g, g_object_attr, auto_parser()) if g.get(g_object_attr) is None: setattr(g, g_object_attr, generate_request_id()) debug(config.request_log_name, get_request_trace_info())
def test_auto_parser_invalid_header(self): with self.app.test_request_context(headers={ 'X-Amzn-Trace-Id': '', 'X-Correlation-ID': '', 'X-Request-ID': '' }): # Wrong headers self.assertIsNone(auto_parser())
def test_auto_parser_precedence_2(self): with self.app.test_request_context( headers={ 'X-Amzn-Trace-Id': 'Root=1-67891233-root', 'X-Correlation-ID': '1-67891233-correlation', }): # Precedence scenario 1 self.assertEqual('1-67891233-correlation', auto_parser())
def test_auto_parser_empty_header(self): with self.app.test_request_context(): # No header should return empty self.assertIsNone(auto_parser())