Registry / web-framework / flask-log-request-id

flask-log-request-id

JSON →
library0.10.1pypypi✓ verified 85d ago

Flask extension that parses and handles request IDs from headers like X-Request-ID, X-Correlation-ID, and Amazon TraceId. Supports Flask and Celery workers. Current version: 0.10.1. Release cadence is low (last release 2021).

pip install flask-log-request-id
INSTALL
IMPORT
SIG · FLASK-LOG-REQUEST-
F
flask-log-request-id
web-frameworkpythonv0.10.1
Install
2.2s avg
Import
478ms
Disk
21MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.10.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.494s · 22.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.2s · import 0.462s · 23MB
21MB installed
● package 21MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

RequestID
from flask_log_request_id import RequestID
from flask.ext.log_request_id import RequestID
Deprecated Flask extension import pattern (Flask <0.12). Use the modern import.
current_request_id
from flask_log_request_id import current_request_id
from flask.ext.log_request_id import get_current_request_id
Function name changed. The proxy is called current_request_id.

Initialize the extension with your Flask app and use current_request_id() to get the current request ID.

from flask import Flask from flask_log_request_id import RequestID, current_request_id app = Flask(__name__) RequestID(app) @app.route('/') def index(): return f"Request ID: {current_request_id()}" if __name__ == '__main__': app.run()
Debug
Known issues
deprecatedThe import pattern flask.ext.log_request_id is deprecated since Flask 0.12. Use the modern import flask_log_request_id.
fix
Use from flask_log_request_id import RequestID instead.
affects: Flask >=0.12
gotchaThe extension does not work out-of-the-box with debug=True in Flask development server (Werkzeug) because the server does not send request IDs by default.
fix
Either set an environment variable or use a middleware to inject a test request ID header.
affects: all
gotchaWhen using Celery, the request ID is only propagated if you explicitly initialize the extension with the Celery app or use the provided helper.
fix
Call init_celery(app, celery) or use the Celery integration documented in README.
affects: all
Errors
Common errors & fixes
AttributeError: module 'flask_log_request_id' has no attribute 'current_request_id'
Typo or wrong import path. Common mistake: using 'current_request_id' instead of 'current_request_id' (underscore). Also check if you imported the correct symbol.
fix
Use: from flask_log_request_id import current_request_id
flask.exceptions.ImportError: cannot import name 'RequestID' from 'flask.ext.log_request_id'
Using the deprecated import pattern flask.ext.log_request_id which is not supported in newer Flask versions.
fix
Replace with: from flask_log_request_id import RequestID
RuntimeError: Working outside of request context.
Calling current_request_id() outside of a Flask request context (e.g., in a background thread).
fix
Ensure you are inside a request context, or pass the request ID explicitly to the background task.
Upgrade
Version history
0.10.1latest on PyPI · released Oct 31, 2019
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
2
Resources
flask-log-request-id — pip install flask-log-request-id · libregistry