Skip to content

Commit 43b5732

Browse files
If tracing id not found in header, using function then uuid
1 parent 368ed7e commit 43b5732

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drf_api_logger/middleware/api_logger_middleware.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,15 @@ def __call__(self, request):
110110
if self.DRF_API_LOGGER_ENABLE_TRACING:
111111
if self.DRF_API_LOGGER_TRACING_ID_HEADER_NAME:
112112
tracing_id = headers.get(self.DRF_API_LOGGER_TRACING_ID_HEADER_NAME)
113-
else:
113+
if not tracing_id:
114+
"""
115+
If tracing is is not present in header, get it from function or uuid.
116+
"""
114117
if self.tracing_func_name:
115118
tracing_id = self.tracing_func_name()
116119
else:
117120
tracing_id = str(uuid.uuid4())
118-
request.tracing_id = tracing_id
121+
request.tracing_id = tracing_id
119122

120123
# Code to be executed for each request before
121124
# the view (and later middleware) are called.

0 commit comments

Comments
 (0)