Bump version to 0.1.3; enhance logging with correlation_id for better error tracing and add request lifecycle middleware
This commit is contained in:
@@ -60,6 +60,7 @@ The proxy defaults to Opus because this deployment is intended for users whose N
|
||||
- As a Claude Code user, I can use tool calls and tool results.
|
||||
- As a multimodal user, I can send images through Claude-compatible image content blocks.
|
||||
- As a developer debugging setup, I can enable verbose logs without exposing tokens.
|
||||
- As a developer debugging issues, I can trace any error in the log file using a correlation_id that appears in both the client response and the log entry.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
@@ -70,6 +71,7 @@ The proxy defaults to Opus because this deployment is intended for users whose N
|
||||
- `--dev` startup reads current-directory `nexus-claude-api.local.json` instead of user config.
|
||||
- Default logs are written to `~/.config/nexus-claude-api/logs/nexus-claude-api-YYYY-MM-DD.log`.
|
||||
- `--dev` logs are written to current-directory `logs/nexus-claude-api-YYYY-MM-DD.log`.
|
||||
- All API errors (4xx, 5xx, network failures, client disconnects) are logged with correlation_id and duration.
|
||||
- Missing Nexus credentials fail fast with a clear error.
|
||||
- `GET /health` returns healthy status.
|
||||
- `GET /v1/models` returns the supported Claude models.
|
||||
|
||||
@@ -29,7 +29,9 @@ nexus-claude-api/
|
||||
__main__.py
|
||||
cli.py
|
||||
config.py
|
||||
diagnostics.py
|
||||
errors.py
|
||||
logging_config.py
|
||||
models.py
|
||||
nexus_client.py
|
||||
server.py
|
||||
@@ -212,6 +214,28 @@ Status mapping:
|
||||
- Nexus throttling: `429`
|
||||
- Nexus network/timeout: `502` or `504`
|
||||
- unexpected server error: `500`
|
||||
- client disconnected: `499` (logged only, not sent)
|
||||
|
||||
## Observability
|
||||
|
||||
All errors are logged to the daily log file with a `correlation_id` for tracing.
|
||||
|
||||
Request lifecycle middleware logs:
|
||||
|
||||
- `request_complete` with method, path, status, and duration_ms for every `/v1/messages` request.
|
||||
- `client_disconnected` when the client drops connection mid-request or mid-stream.
|
||||
- `unhandled_exception` with traceback for unexpected errors (returns 500).
|
||||
|
||||
Error logging at point of origin:
|
||||
|
||||
- `nexus_client_error` (WARNING): Nexus API returned an error (4xx/5xx) with error code, message, HTTP status, and request ID.
|
||||
- `nexus_botocore_error` (WARNING): Network/transport failure (timeout, DNS, connection reset).
|
||||
- `stream_nexus_error` (WARNING): Error during streaming response iteration.
|
||||
- `stream_client_disconnected` (INFO): Client closed connection during streaming.
|
||||
- `validation_error` (WARNING): Malformed request that failed pydantic validation.
|
||||
- `nexus_error` (WARNING): NexusClaudeError in non-streaming response path.
|
||||
|
||||
Diagnostics summarize each request (model, stream flag, message count, content block types, tool info) without logging secrets, prompt text, or base64 data.
|
||||
|
||||
## Testing
|
||||
|
||||
@@ -234,6 +258,11 @@ Route tests:
|
||||
- `POST /v1/messages` non-stream
|
||||
- `POST /v1/messages` stream
|
||||
- `POST /v1/messages/count_tokens`
|
||||
- Validation errors are logged with correlation_id.
|
||||
- Nexus errors (non-stream) are logged with status and type.
|
||||
- Nexus errors (stream) are logged as `stream_nexus_error`.
|
||||
- Request completion is logged with duration_ms.
|
||||
- Unexpected exceptions return 500 and are logged.
|
||||
|
||||
CLI tests:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user