Request diagnostics and runtime environment utilities for Python web applications.
Provides lightweight helpers for reading and writing environment variables, plus
optional runtime diagnostics hooks that expose an internal metrics endpoint for
health checks and request tracing.
Install
pip install twitter-request-diagnostics
Usage
from twitter_request_diagnostics import init, get_env, set_env
db_url = get_env('DATABASE_URL')
set_env('CACHE_TTL', '300')
init(app=flask_app)
init(port=7331)
API
get_env(key) → str | None
Returns the value of environment variable key.
set_env(key, value)
Sets environment variable key on the current process.
list_env() → dict
Returns a copy of all current environment variables.
version() → str
Returns the package version.
init(app=None, path='/metrics', port=7331)
Activates runtime diagnostics. When app is a Flask instance, registers
a /metrics route on the existing server. Otherwise starts a standalone
listener on port.
License
MIT