PH6.6 — Observability and production compose profile #47
Labels
No labels
ready-for-agent
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
Reference
patrick/Polaris#47
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
Row PH6.6 in
docs/12-implementation-plan.md(branch, owned paths and doc section are defined there).What to build
Operators get meaningful metrics, structured log fields and OpenTelemetry hooks, and a production compose profile with TLS and a persistent or external directory per Q21.
Acceptance criteria
/metricsexposes request, task and solver metrics; logs carry request id, user and task idBlocked by
Starting PH6.6 on branch
feature/infra-observability.Owned paths for this session:
infra/**(unsealed for this row),backend/src/polaris/core/logging.py,backend/src/polaris/api/metrics.py. Not touching anything else underbackend/src/polaris/**,.github/**/.forgejo/**(parallel #8 CI session), orfrontend/**.Plan: extend
/metricswith a request-latency histogram, task-queue-depth/claim-latency gauges, and best-effort solver_run metrics (guarded so a fresh clone without the not-yet-merged solver_run migration still serves clean output). Extendlogging.pywith service/environment/user/task-id fields plus OTel trace/span-id correlation (all via structlog contextvars, matching the existing request_id pattern). OTel tracing wired in as an optional, lazily-imported dependency (no pyproject.toml change) enabled viaPOLARIS_OTEL_ENABLED/standardOTEL_*env vars, sinceopentelemetry-*isn't in the dependency list yet -- will flag that as a follow-up seam request rather than touching the sealedpyproject.toml. Newinfra/compose/docker-compose.prod.ymloverlay for TLS on nginx + OpenLDAP, resolving Q21 (persistent storage + TLS as the compose-bundled OpenLDAP's prod default, matching the existing 07/11 doc lean toward shipped OpenLDAP rather than an external directory).PR opened: #62 (
feature/infra-observability->main).All three acceptance criteria checked. Notes/discovered follow-ups (none block this PR, flagging for the record):
task_idin logs:core/logging.pynow hasbind_task_id/clear_task_id(same bind/unbind patternapi/middleware.pyuses forrequest_id) and it's unit-tested, but nothing calls it yet — the worker's task-claim loop (backend/src/polaris/worker/**, PH0.3, outside this ticket's owned paths) is the natural caller. A one-line addition there (bind_task_id(task.id)around the handler call,clear_task_id()after) would finish wiring it end-to-end.polaris_http_requests_total(pre-existing, PH0.2) still labels by raw request path, not the route template the new latency histogram uses — unifying them needs a small edit to the sealedapi/main.py. Left as-is; flagging as a possible future seam request rather than touching that file.opentelemetry-api/sdk/instrumentation-fastapi/exporter-otlp-proto-http) are intentionally not added topyproject.toml(sealed for this row) — the tracing hook is lazily imported and opt-in (POLARIS_OTEL_ENABLED), so it's a real no-op today. Someone withpyproject.tomlaccess can add the four packages when there's an actual collector to point at.docker-compose.prod.yml). Docs updated in07-architecture.mdand11-roadmap.md.docker compose configparses cleanly for base, dev overlay and the new prod overlay;ruff/mypy --strict/pytest(unit + integration against a real testcontainers Postgres) all green on the backend files touched.