Middleware for propagating and logging correlation IDs across ASGI applications to trace HTTP requests.
ASGI Correlation ID is a Python middleware library that adds correlation ID propagation to ASGI web applications. It solves the problem of tracing logs across distributed systems by attaching a unique identifier to each HTTP request, making it easy to filter and correlate logs generated during that request's lifecycle.
Backend developers building ASGI-based web applications with FastAPI, Starlette, or similar frameworks who need improved logging and request tracing capabilities.
Developers choose ASGI Correlation ID for its simplicity, framework-agnostic design, and seamless integration with existing logging setups and third-party tools like Sentry and Celery, providing immediate observability improvements with minimal configuration.
Request ID propagation for ASGI apps
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Works with any ASGI-compatible framework such as FastAPI and Starlette, allowing consistent integration across different projects without framework-specific code.
Provides a logging filter that easily injects correlation IDs into Python's standard logging and structlog, as demonstrated in the configuration examples for immediate observability improvements.
Supports customization of header names, ID generators, validators, and transformers, offering flexibility for various use cases, such as using nanoid or custom validation logic.
Includes integrations for Sentry and Celery, automatically propagating correlation IDs to enhance observability in distributed tasks and error tracking without additional dependencies for core features.
Setting up the logging filter necessitates modifying the logging dictionary or configuration, which can be complex and error-prone for developers unfamiliar with Python's logging module, as shown in the detailed setup steps.
Only compatible with ASGI frameworks, excluding popular WSGI-based applications unless they are adapted to ASGI, which limits its applicability in mixed or legacy environments.
Handling CORS headers and exception responses requires extra code, as documented in the README, adding complexity to the setup process and potential for misconfiguration.