in src/Backend/src/api/middleware.py [0:0]
def _get_trace(self, request: starlette.requests.Request) -> str | None:
"""
Get trace path from request.
Build the trace path from the request. The trace identifier is extracted from
the TraceParent header, and then combined with the project identifier to form
the trace path.
Header Example: `00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01`
Documentation on the header format can be found here:
https://www.w3.org/TR/trace-context/#traceparent-header-field-values
:param request: request object
:returns: trace id or None if not found
"""
if (value := request.headers.get("traceparent")) and value[:3] == "00-":
trace_id = value.split("-")[1]
return f"projects/{self.project_id}/traces/{trace_id}"
return None