Observability
CloudWatch metrics
Published through utils/metric_utils.py → pyb-sdk CriticalMetricNamespace
(PybUserProcess.UNDERWRITING, PybService.INTG, process_name = automatic-uw-tool). Metric
publication never fails a request or a task — errors are caught and logged.
Worker (swf_app.py)
| Metric | Unit | Emitted |
|---|---|---|
|
count |
Any exception while building or executing an activity (only when the task object was built). |
|
seconds |
Successful activity, wall-clock from poll to completion. |
{process_name} is task.get_process_name(), so both Au10tix and Entrust report under
validate_identity_document.
Web API
One timing metric per endpoint, emitted on every call including error paths:
-
execute_endpoint_time_taken -
get_task_result_endpoint_time_taken -
get_task_status_endpoint_time_taken -
delete_task_results_endpoint_time_taken -
update_final_statuses_endpoint_time_taken -
get_tools_endpoint_time_taken -
create_entrust_session_endpoint_time_taken
Because success and failure share a metric name, latency alone will not tell you a call failed — pair these with the Sentry stream and the task statuses.
Logs
| Stream | Contents |
|---|---|
Web API ( |
|
SWF worker |
Task loggers, one per task, prefixed with the correlation id: |
|
Request payloads are logged verbatim, so |
Sentry
sentry_sdk.init runs in both entry points:
-
Web API —
environment = settings.ENV_NAME, plusSentryAsgiMiddlewarefor unhandled request errors. -
Worker —
environment = settings.SENTRY_ENV(productioninrelease, the env name otherwise),traces_sample_rate = 1.0, and an explicitcapture_exception()for every failed activity.
Also reported deliberately: HubSpot sync failures and supplier-event failures — HubSpotClient
and SupplierEventLogger both capture their own exceptions because they swallow them.
Audit trails inside the data
Observability is not only CloudWatch:
| Source | Answers |
|---|---|
|
Did the execution finish? |
|
Who changed a verdict or a tool, when, and under which |
|
Verdict history: versions are kept per |
S3 datalake |
The raw vendor evidence behind a verdict — for Entrust, including every workflow step’s input and output. |
Internal EventLogger |
The supplier’s Entrust lifecycle as supplier-timeline events ( |
SWF console |
Activity input, result and failure |
Health checks
GET /health-check returns {"status": "OK"} unauthenticated — used by the ALB target group.
It is a liveness probe only: it does not verify DynamoDB, SWF or vendor connectivity.
The worker exposes no health endpoint. Its liveness is visible as SWF activity throughput and the
_success_time_taken metric; a wedged worker shows up as tools stuck PENDING (surfaced as
ERROR by GET /tools after 300 s).
Suggested alarms
Not currently defined in this repository, but the useful signals are:
-
{process}_failurecount above zero over a short window, per process. -
{process}_success_time_takenp95 rising — vendor slowdown. -
Sentry error-rate spikes on
ThomsonReutersNotWorking,RetryException, orHTTPErrorfrom the internal document API (an Entrust upload rejection). -
Tools left
PENDINGbeyond the 300 s window, which indicates the worker is not draining the task list.