Skip to content

Refactor gateway logging flow to centralized middleware pattern #51

@wauputr4

Description

@wauputr4

Context

PR #48 already moved request-log persistence off the response path and stopped hardcoding method/path in the logging helper.

The remaining work is a maintainability refactor: the gateway still has several manual completion-log call sites in crates/mizan-api/src/gateway.rs, which makes future endpoint additions harder to keep consistent.

Proposed changes

  • Centralize gateway completion logging behind one helper or layer boundary so handler branches do not repeat completion plumbing.
  • Keep the request-log schema and existing fields unchanged.
  • Preserve current success/error semantics for chat completions.
  • Make the logging path reusable for future non-chat gateway endpoints.

Acceptance Criteria

  • Completion logging is centralized instead of repeated in each branch.
  • Success and error paths still emit the same request-log fields.
  • Existing async persistence behavior remains intact.
  • Add tests or integration assertions for at least one success path and one error path.
  • Document the tradeoffs if a middleware/layer pattern is introduced.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: gatewayGateway routing and OpenAI-compatible API surfacearea: observabilityTracing, logs, metrics, and diagnosticsenhancementNew feature or requestrustPull requests that update rust code

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions