Skip to content

perf: admin log collector runs on the hot path even when the admin API is disabled #112

Closed

Description

@skyoo2003

Context

Surfaced during code review of #111 (finding 4, skipped as pre-existing).

Problem

cmd/devcloud/main.go always builds a 1000-entry admin.LogCollector, and the gateway's logging middleware (internal/gateway/gateway.go, in New) calls logCollector.Add(...) — a mutex lock + ring-buffer insert — on every AWS request, regardless of admin.enabled.

When admin.enabled: false (the default), nothing can ever read those logs without a restart, so every request pays for bookkeeping no consumer can reach.

Why it was deferred

Pre-existing behavior (not introduced by #111). Conditionalizing it requires a gateway.New signature/behavior change (e.g. inject an optional collector or a no-op), which is out of proportion to that PR's diff.

Suggested fix

Make the log collector optional: when admin is disabled, skip the Add call (nil collector / no-op recorder) so the middleware short-circuits on the hot path. Keep behavior identical when admin is enabled.

Acceptance

  • No logCollector.Add work per request when admin.enabled: false.
  • Admin-enabled behavior (recent-logs endpoint) unchanged, still covered by tests.

Activity

  1. self-assigned this
    on Jul 24, 2026
  2. added a commit that references this issue on Jul 24, 2026
    5b25062
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

choreMaintenance task

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions