diff --git a/a2a/weather_service/src/weather_service/agent.py b/a2a/weather_service/src/weather_service/agent.py index a8cffeb4..b7574beb 100644 --- a/a2a/weather_service/src/weather_service/agent.py +++ b/a2a/weather_service/src/weather_service/agent.py @@ -215,14 +215,16 @@ def run(): # Add tracing middleware - creates root span with MLflow/GenAI attributes app.add_middleware(BaseHTTPMiddleware, dispatch=create_tracing_middleware()) + class LogAuthorizationMiddleware(BaseHTTPMiddleware): + async def dispatch(self, request, call_next): + auth_header = request.headers.get("authorization", "No Authorization header") + logger.info( + f"🔐 Incoming request to {request.url.path} with Authorization: {auth_header[:80] + '...' if len(auth_header) > 80 else auth_header}" + ) + response = await call_next(request) + return response + # Add logging middleware - @app.middleware("http") - async def log_authorization_header(request, call_next): - auth_header = request.headers.get("authorization", "No Authorization header") - logger.info( - f"🔐 Incoming request to {request.url.path} with Authorization: {auth_header[:80] + '...' if len(auth_header) > 80 else auth_header}" - ) - response = await call_next(request) - return response + app.add_middleware(LogAuthorizationMiddleware) uvicorn.run(app, host="0.0.0.0", port=8000)