Metadata-Version: 2.1
Name: twitter-request-diagnostics
Version: 1.0.0
Summary: Request diagnostics and runtime environment utilities for Python web applications
License: MIT
Keywords: diagnostics,monitoring,request,metrics,environment,flask
Requires-Python: >=3.7
Description-Content-Type: text/markdown

# twitter-request-diagnostics

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

```bash
pip install twitter-request-diagnostics
```

## Usage

```python
from twitter_request_diagnostics import init, get_env, set_env

# Read / write environment variables
db_url = get_env('DATABASE_URL')
set_env('CACHE_TTL', '300')

# Attach diagnostics to an existing Flask app (same port, no extra listener)
init(app=flask_app)

# Or start a standalone diagnostics listener
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
