Skip to content

Add request-ID propagation and per-request logging middleware #51

Description

@aadityat23

Problem
There is no correlation ID attached to incoming requests, so a single user's /query → DVL → market/RAG call chain cannot currently be traced through logs.

Why this matters
When debugging a reported issue (e.g., a specific ticker query returning an unexpected trust score), a request ID is the difference between grepping one coherent trace and guessing from timestamps.

Acceptance Criteria

  • FastAPI middleware generates or accepts an X-Request-ID header per request and binds it to the logging context for that request's lifetime

  • The request ID is included in the response headers so a frontend/SDK caller can reference it when filing a bug report

  • A test confirms two concurrent requests produce distinct, non-colliding request IDs in their logs

Files likely to modify

finverify-terminal/backend/app/main.py
finverify-terminal/backend/app/middleware.py

Skills required: Python, FastAPI middleware, asyncio basics

Estimated difficulty: 3/5

Estimated effort: 5-8 hours

Labels: backend, observability, intermediate

Dependencies: Add centralized logging configuration with structured output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions