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():
63
63
logger .exception ("Error occurred" , exc_info = e )
64
64
return {}
65
65
66
+ @app .route ("/get-correlation-id" )
67
+ def get_correlation_id ():
68
+ return {'correlation_id' : json_logging .get_correlation_id ()}
69
+
66
70
with app .test_client () as test_client :
67
71
yield test_client , handler
68
72
@@ -121,6 +125,16 @@ def test_correlation_id_generated(client_and_log_handler):
121
125
), "autogenerated UUID doesn't have expected format"
122
126
123
127
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
+
124
138
def test_extra_property (client_and_log_handler ):
125
139
"""Test adding an extra property to a log message"""
126
140
api_client , handler = client_and_log_handler
You can’t perform that action at this time.
0 commit comments