semantics

This commit is contained in:
2026-05-12 20:06:16 +03:00
parent 9ea177558b
commit fe8978f716
461 changed files with 31360 additions and 25040 deletions

View File

@@ -1,7 +1,5 @@
# [DEF:TraceContextMiddlewareModule:Module]
# @COMPLEXITY: 3
# @SEMANTICS: middleware, trace, context, starlette, fastapi
# @PURPOSE: FastAPI/Starlette middleware that seeds a trace_id for every incoming HTTP request.
# #region TraceContextMiddlewareModule [C:3] [TYPE Module] [SEMANTICS middleware, trace, context, starlette, fastapi]
# @BRIEF FastAPI/Starlette middleware that seeds a trace_id for every incoming HTTP request.
# Optionally extracts X-Trace-ID header for cross-service trace propagation.
# @LAYER: Core
# @RELATION: [DEPENDS_ON] -> [CotLoggerModule]
@@ -18,10 +16,8 @@ from starlette.types import ASGIApp
from ..cot_logger import seed_trace_id, set_trace_id
# [DEF:TraceContextMiddleware:Class]
# @COMPLEXITY: 2
# @SEMANTICS: middleware, trace, context, dispatch
# @BRIEF: Starlette BaseHTTPMiddleware that seeds a trace_id per request.
# #region TraceContextMiddleware [C:2] [TYPE Class] [SEMANTICS middleware, trace, context, dispatch]
# @BRIEF Starlette BaseHTTPMiddleware that seeds a trace_id per request.
class TraceContextMiddleware(BaseHTTPMiddleware):
"""FastAPI/Starlette middleware that seeds a trace_id for every request.
@@ -35,17 +31,15 @@ class TraceContextMiddleware(BaseHTTPMiddleware):
app.add_middleware(TraceContextMiddleware)
"""
# [DEF:TraceContextMiddleware.__init__:Function]
# @BRIEF: Standard BaseHTTPMiddleware initialiser.
# #region TraceContextMiddleware.__init__ [TYPE Function]
# @BRIEF Standard BaseHTTPMiddleware initialiser.
def __init__(self, app: ASGIApp) -> None:
super().__init__(app)
# [/DEF:TraceContextMiddleware.__init__:Function]
# #endregion TraceContextMiddleware.__init__
# [DEF:TraceContextMiddleware.dispatch:Function]
# @COMPLEXITY: 2
# @SEMANTICS: dispatch, trace, seed, header, call_next
# @BRIEF: Dispatch handler that seeds trace_id before passing to the next middleware.
# #region TraceContextMiddleware.dispatch [C:2] [TYPE Function] [SEMANTICS dispatch, trace, seed, header, call_next]
# @BRIEF Dispatch handler that seeds trace_id before passing to the next middleware.
async def dispatch(
self, request: Request, call_next
) -> Response:
@@ -70,8 +64,7 @@ class TraceContextMiddleware(BaseHTTPMiddleware):
response = await call_next(request)
return response
# [/DEF:TraceContextMiddleware.dispatch:Function]
# #endregion TraceContextMiddleware.dispatch
# [/DEF:TraceContextMiddleware:Class]
# [/DEF:TraceContextMiddlewareModule:Module]
# #endregion TraceContextMiddleware