Skip to content

Add request/response logging with correlation IDs #28

@Asi0Flammeus

Description

@Asi0Flammeus

Description

The API lacks comprehensive logging and request tracking, making debugging and monitoring difficult.

Problems

  • No correlation IDs to track requests across operations
  • Missing structured logging for API operations
  • Difficult to trace issues through async operations
  • No request/response logging for debugging

Requirements

  • Add correlation ID generation for each request
  • Implement structured logging with consistent format
  • Log request/response details (sanitized for security)
  • Add correlation ID to error responses
  • Include timing information in logs
  • Add log levels for different severity

Implementation

import uuid
from fastapi import Request

@app.middleware("http")
async def add_correlation_id(request: Request, call_next):
    correlation_id = str(uuid.uuid4())
    request.state.correlation_id = correlation_id
    # Add to logs and response headers

Acceptance Criteria

  • Every request gets a unique correlation ID
  • Structured logging throughout the application
  • Correlation IDs in error responses and logs
  • Request timing information logged
  • Sensitive data excluded from logs

Related

Priority

Medium - Operational improvement

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions