@factory/observability
OpenTelemetry SDK init, stable metric registry, span scrubber, traceparent
propagation, and the pino correlation bridge for AI Software Factory
(TASK-0135, Phase 15 observability). Source-first package — main/types
point at the TS source (no build step, the packages/shared pattern). The
four apps import from here; the pull-side counterpart is the infra stack in
infrastructure/observability/ (Prometheus / Grafana / Alertmanager).
Subpath exports
| Export | Contents |
|---|---|
. |
Public surface (re-exports of the modules below) |
./otel |
initOtel / shutdownOtel / isOtelEnabled / getOtelState, startSpan / startAsyncSpan (gated on OTEL_ENABLED) |
./resource |
SERVICE_NAMES (factory-web, factory-api, factory-worker, factory-realtime) + buildResource (semantic-convention resource attributes) |
./metrics |
Stable metric registry — METRIC_NAMES, instrument factories, setQueueDepth / setWsConnections gauges, shared DURATION_BUCKETS |
./scrubber |
spanScrubber (no PII/secrets in span attributes) + redactQuery (SQL text → operation shape) |
./traceparent |
W3C traceparent capture/resume (API → worker job metadata → processor span), registerTraceparentPropagator |
./pino-otel |
makeOtelPino / otelLogBindings / requestChild — requestId on every log line |
Tests
pnpm --dir packages/observability test # vitest
pnpm --dir packages/observability typecheck