Rewrite every log call as an event name with typed fields

Prose f-strings become past-tense events with consistent field names
across services (account_id, transaction_id, amount_minor, risk_score,
status_code, consumer_group, message_id, chaos_flag). The orchestrator
and both consumers move from logging.getLogger to structlog so they can
pass fields.

New events cover what was silent before: the gateway's UpstreamFailure
path (transaction_failed, with the underlying cause), fraud's score and
sanctions' screening outcomes, and each successfully processed stream
message. holder_name is no longer logged at all.

"lookup" and "healthz" still appear in exactly one event each, so the
pathology tests' log-line counts are unchanged until they move to LogQL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Movses Aslanyan
2026-10-13 21:09:55 +03:30
co-authored by Claude Opus 5.5
parent 560e3afa0e
commit bc11638a15
9 changed files with 100 additions and 38 deletions
+8
View File
@@ -118,6 +118,14 @@ async def submit_transaction(body: TransactionRequest):
try:
result = await orchestrator.create_transaction(body.model_dump())
except UpstreamFailure as exc:
log = logger.error if exc.status_code >= 500 else logger.warning
log(
"transaction_failed",
account_id=body.account_id,
status_code=exc.status_code,
reason=exc.message,
cause=repr(exc.__cause__) if exc.__cause__ else None,
)
return JSONResponse(
status_code=exc.status_code, content={"error": exc.message, "request_id": request_id}
)