File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,10 @@ def log_exception():
6363 logger .exception ("Error occurred" , exc_info = e )
6464 return {}
6565
66+ @app .route ("/get-correlation-id" )
67+ def get_correlation_id ():
68+ return {'correlation_id' : json_logging .get_correlation_id ()}
69+
6670 with app .test_client () as test_client :
6771 yield test_client , handler
6872
@@ -121,6 +125,16 @@ def test_correlation_id_generated(client_and_log_handler):
121125 ), "autogenerated UUID doesn't have expected format"
122126
123127
128+ def test_get_correlation_id (client_and_log_handler ):
129+ """Test if json_logging.get_correlation_id() finds a given correlation ID"""
130+ api_client , handler = client_and_log_handler
131+
132+ response = api_client .get ("/get-correlation-id" , headers = {"X-Correlation-Id" : "abc-def" })
133+
134+ assert response .status_code == 200
135+ assert response .json ["correlation_id" ] == "abc-def"
136+
137+
124138def test_extra_property (client_and_log_handler ):
125139 """Test adding an extra property to a log message"""
126140 api_client , handler = client_and_log_handler
You can’t perform that action at this time.
0 commit comments