Skip to content

Backend chat observability: add standardized request summary logs#147

Closed
akgohain wants to merge 1 commit into
mainfrom
codex/standardize-logging-for-chat-endpoints-g4ta22
Closed

Backend chat observability: add standardized request summary logs#147
akgohain wants to merge 1 commit into
mainfrom
codex/standardize-logging-for-chat-endpoints-g4ta22

Conversation

@akgohain
Copy link
Copy Markdown
Collaborator

Motivation

  • Provide consistent, single-line structured observability for chat endpoints so stalls/errors can be diagnosed quickly with minimal parsing.
  • Ensure every chat request emits a compact summary containing request_id, endpoint, latency_ms, status, and error_type while preserving existing verbose behavior.
  • Avoid logging sensitive request payloads or field context.

Description

  • Add a module logger and request-timing/request-id helpers to server_api/main.py and emit a single-line JSON summary for /chat/query and /chat/helper/query in a finally block.
  • Generate request_id from the incoming x-request-id header or a new uuid4, capture endpoint from req.url.path, compute latency_ms via time.perf_counter(), and record status (ok/error) and error_type when exceptions occur.
  • Keep all existing endpoint logic and DB persistence unchanged; logging only emits metadata (no query, fieldContext, message content, or other payloads) to avoid sensitive data leakage.
  • Add targeted tests tests/test_chat_logging_fields.py that capture logger output with self.assertLogs and assert presence and types of the standardized fields for a success path and an error path.

Testing

  • Ran PYTHONPATH=. pytest -q tests/test_chat_logging_fields.py which passed (2 passed) verifying both success and error logging behaviors.
  • Attempted uv run pytest -q tests/test_chat_logging_fields.py but it failed in this environment due to packaging/metadata for the editable pytorch_connectomics dependency (unrelated to the changes); the focused PYTHONPATH invocation was used to validate the new tests.
  • No other automated tests were modified and existing endpoint behavior was preserved by the implementation.

Codex Task

@akgohain
Copy link
Copy Markdown
Collaborator Author

Consolidated into draft PR #165 (feat/codex-wave-integration). Closing this source draft to keep review in one place.

@akgohain akgohain closed this Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant