Bootstrap OpenTelemetry in workers, Batch and Lambda - #1578
Conversation
fac39ed to
d314fe5
Compare
e10e4ac to
18fbd12
Compare
db214e3 to
cf4ca1c
Compare
18fbd12 to
6a0c2e5
Compare
fe2fda1 to
0cd73b4
Compare
|
Claude finished @Nazehs's task in 1m 29s —— View job PR Review: Bootstrap OTel in workers, Batch and LambdaClean, well-guarded seam. The no-op path is correct and tests cover the key branches.
🔴 DO — eliminate the triplication. A copy step in the build or a shared Lambda layer means a single source of truth; right now a one-line fix requires three identical edits. Fix this → ⚪️ NIT — Adds OTel spans to RQ jobs, Batch scripts, and all three Lambdas behind a dual-flag guard. No-op by default; flushes correctly at each execution boundary. |
0cd73b4 to
417d26f
Compare
|
Claude finished @Nazehs's task in 1m 34s —— View job PR Review: Bootstrap OTel in workers, Batch and Lambda
Triplication resolved correctly —
🔵 CONSIDER — these two files are still ~identical: same
⚪️ NIT —
⚪️ NIT (from previous review, still unaddressed) — Solid, well-guarded seam. No-op path is correct, flush happens at every execution boundary, and Lambda triplication is resolved. |
417d26f to
de00aa5
Compare
|
Claude finished @Nazehs's task in 1m 3s —— View job PR Review: Bootstrap OTel in workers, Batch and Lambda
Previous NITs addressed:
🔵 CONSIDER — Clean implementation. No bugs found. |
This is intentional to keep the duplication low and there is a ticket already created to address this duplication in tech debt later in the future and then this will be fully handled https://linear.app/iai-consult/issue/PRO-573/extract-shared-code-across-the-3-lambda-functions |
Import-safe, endpoint-guarded OTel helper (bootstrap_otel, execution_span, flush_otel) shared by the Batch scripts. Stays a no-op until OTEL_EXPORTER_OTLP_ENDPOINT is set and the util [otel] extra is pinned, so nothing changes at runtime yet. (PRO-648)
Bootstrap OTel from bootstrap_logger and wrap each script's work in an execution_span carrying context_id and consultation_code, flushing at the process boundary. No auto-instrumentation exists for Batch, so this root span is what makes the run's logs correlatable once the endpoint is wired. (PRO-648)
Worker-only OTel seam (gated on EXECUTION_CONTEXT == worker) that wraps each RQ job in an execution_span carrying the same context_id the logs bind, flushing at the job boundary since a worker can idle after. Import-safe and endpoint-guarded, so it stays a no-op until the extra is pinned. (PRO-648)
Vendor the OTel seam into each Lambda and wrap the handler body in an execution_span carrying context_id, flushing in finally so short-lived invocations still ship telemetry. The bootstrap catches ImportError and the endpoint-required RuntimeError, so a cold start never crashes before the endpoint and util extra land. (PRO-648)
de00aa5 to
42bede1
Compare
|
Claude finished @Nazehs's task in 59s —— View job PR Review: Bootstrap OTel in workers, Batch and Lambda
Previous feedback addressed. No bugs found.
⚪️ NIT — Clean, no-op by default, flushes correctly at all execution boundaries. |
Context
Bootstraps OpenTelemetry on the surfaces with no auto-instrumentation: the RQ worker, the Batch scripts, and the import/notifier Lambdas. Without a root span per run their logs can't be correlated. It's a drop-in seam guarded on the
OTEL_ENABLEDflag and a collector endpoint, so it stays a no-op until both are set.Changes proposed in this pull request
bootstrap_otel,execution_span,flush_otel) to pipeline-common, the backend, and each Lambda.context_idandconsultation_code, so logs correlate on the same id.ImportErrorand the endpoint-requiredRuntimeErrorin the Lambda bootstrap so a cold start degrades to a warning, not a crash.Things to check
.env.testfiles in the repo