Skip to content

perf(observability): cut routine log volume (listen access records, sync per-segment INFO, queue + gateway sampling) - #23676

Merged
Git-on-my-level merged 4 commits into
mainfrom
lane/n7-logging-tail
Oct 26, 2026
Merged

Git-on-my-level merged 4 commits into
mainfrom
lane/n7-logging-tail

Conversation

@Git-on-my-level

Copy link
Copy Markdown
Member

What changed and why

Logging-cost tail (margin-50 N7): four routine-noise cuts with no metric, alert,
or dashboard consumers. Measured 7d (10-19..10-25, ro-prod, billing +
logging.googleapis.com/byte_count): Log Storage $38.8/day, and two log storms
in four days (10-22 backend-sync 50 GiB; 10-25 sync+backfill 99 GiB, $66 that
day).

  1. listen access records off (main.py): access_policy='platform' is
    already the effective policy on Cloud Run; on this entrypoint's only GKE
    deployment (backend-listen) it stops the per-request uvicorn access records
    that grew 2.8M → 21-26M INFO lines/day on 10-23 (now the fleet's largest
    single stdout source, ~23 GiB/day ≈ $310/mo) and duplicate the fronting LB's
    request records. Supersedes the runbook's "keep general access records for
    listen until route coverage is proven" (2026-10-26, at ~8× the volume that
    ruling was made at); WARNING+ app records and VADGate lines are unaffected.
    llm-gateway and diarizer-batch keep their access records.
  2. Sync routine lifecycle INFO → DEBUG (per-segment success outcome,
    per-file sync_vad success and audio_merge: built artifact, per-dispatch
    outcome=enqueued, sync_assignment outcome=superseded, retry
    outcome=deduplicated): rates stay observable via
    omi_sync_transcription_* / omi_sync_dispatch_* metrics; the per-job
    status=finalized summary and all WARNING+ / error-outcome lines stay INFO;
    per-job terminal outcomes (outcome=skipped|superseded|reconciled,
    deferrals) stay INFO for two-lane triage. None of the 26 logs-based metrics,
    the sentinel phrase filters (sync_lane_admission, sync_reprocess +
    outcome=error), or the vad-streaming sink matches a demoted phrase.
  3. Cloud Tasks log_sampling_ratio 1.0 → 0.1 on sync-jobs-fresh and
    sync-backfill-fresh (2.8 GiB/day of task_operations_log): queue
    depth/age alerting uses platform metrics; no logs-based metric reads
    task-op logs.
  4. Loki gateway verboseLogging: false (1.9 GiB/day of nginx access lines
    billed at ERROR severity; 4xx/5xx still log).

Expected saving ≈ $550-700/mo at current volumes (listen ~$310, sync stdout
~60-70% of ~$250-350 clean-day baseline + proportional storm shrinkage, queues
~$34, gateway ~$25), plus storm insurance (each storm day currently adds
$35-45).

Product invariants affected

none

How it was verified

  • Read-only measurement (ro-prod): logging.googleapis.com/byte_count /
    log_entry_count by log × service × severity (metrics only, no entries read),
    billing export daily SKU trend; consumer sweep over the 26 logs-based metric
    filters (gcloud logging metrics list), backend/charts/monitoring
    alerts/dashboards, sentinel phrase filters in
    data/run-2026-10-13-two-lane-nemotron/sentinel/scripts/, and backend tests.
  • BACKEND_UNIT_TEST_FILE_LIST (7 files: sync capture pipeline, omi_logging,
    audio_merge ×3, uid_sequencer, logging entrypoint guard) — 51 passed.
  • Post-deploy checks for the lead: listen stdout entries/day 21M → ~2M
    expected; backend-sync stdout −60-70%; task_operations_log ~2.8 → ~0.3
    GiB/day; gateway nginx stderr → ~0.

Tests

Log-level and config-value changes only; the one behavior-bearing line
(per-segment outcome level) keeps its existing correlation-ref assertions —
test_sync_capture_pipeline.py caplog context widened INFO → DEBUG for the
success-outcome case. No new tests: no control flow, payload, or metric changes.

UI evidence

UI-Evidence: none -- backend logging/config only, no UI change

Failure class (fixes)

Failure-Class: none

Rollout / kill switch

  • Lands via the normal train; queue ratios apply through the next config-train
    plan; Loki via the next prod-omi-loki helm deploy.
  • Kill switches: revert the main.py policy arg (access records return on the
    next listen deploy); revert the logger.debug sites (lines return at INFO);
    log_sampling_ratio: 1.0 in ops/prod.yaml (config-train reapplies);
    verboseLogging: true in the Loki values.
  • No accuracy, speaker-label, latency, or free-plan surface is touched; no
    alert or dashboard input changes (verified above).

…ync per-segment INFO, queue + gateway log sampling)

- main.py: access_policy='platform' stops backend-listen's per-request uvicorn
  access records (~21M INFO lines/day, ~23 GiB/day billed, duplicates the
  fronting LB records); Cloud Run behavior unchanged
- sync pipeline/router/sequencer: demote per-segment/per-file/per-dispatch
  success lifecycle lines to DEBUG; per-job summary, WARNING+ and two-lane
  triage outcomes stay INFO; metrics unaffected
- ops/prod.yaml: sync-jobs-fresh + sync-backfill-fresh log_sampling_ratio 0.1
- loki prod values: gateway verboseLogging false (4xx/5xx still log)
- runbook: record the listen access-policy supersession with the cost basis
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T06:16:56.603081Z fdc9a90 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…aging ops file

test_staging_mirrors_prod_except_names pins staging/prod queue-field parity;
the staging twins of sync-jobs-fresh and sync-backfill-fresh still carried 1.0.
@Git-on-my-level
Git-on-my-level merged commit 2ab8a0c into main Oct 26, 2026
63 of 65 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/n7-logging-tail branch October 26, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant