Repository navigation
Name the database row and Modal call in v2 telemetry, and emit the Simulation Entrypoint's log fields - #1092
Merged
Merged
Conversation
… (failing) Each v2 Modal function's operation record should carry `database_table`, `database_row_id` and `modal_call_id` after the observability package's attribute filter, and its metrics none of them. The US simulation worker should pass its simulation run to the segments it starts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each v2 Modal function's operation now carries `modal_call_id` and, when its call works on a detailed-save row, `database_table` (`household_jobs`, `report_runs` or `simulation_runs`) and `database_row_id`. The US simulation worker passes its simulation run to the segments it starts. The keys avoid the words the observability package's filter drops, and the IDs stay off metrics. The observability guide lists the new identifiers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… after review round 1 The US and UK simulation workers read their Modal call ID and simulation run inside `try`, as the other v2 functions do. The observability guide now says `database_table` is a telemetry-only name and that no row records a segment worker's own Modal call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s (failing) The observability runtime's log handler emits only a record's `policyengine_attributes`, and drops keys naming a household. A `log_extra` helper in the shared observability library should pass each field there; every Entrypoint log call with `extra=` should use it, with no field named by a word the package drops; and the household job logs should name their job as a `household_jobs` row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The observability runtime's log handler emits only a log record's `policyengine_attributes`, so 31 of the Entrypoint's 33 log calls, which passed their fields only as `extra=` keys, wrote records naming no job, report, run or error type. A new `log_extra` helper in the shared observability library puts the fields in both places, and every log call now uses it. Rows are named with `database_table` and `database_row_id` (`database_row_attributes`), since the runtime drops a key such as `household_job_id`; the v2 Modal functions' operations take the same names from the shared module. A budget window's started years are joined into one string, since the runtime drops lists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ble (failing) After review round 2: the Entrypoint's INFO records should reach the observability runtime's handler, which the root logger's WARNING level stops today; a field named like a LogRecord attribute should be emitted instead of making the log call raise; the economy, household report and budget window logs should name their `reports` or `simulations` row; and the static check gets proof fixtures for its rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er review round 2 The Entrypoint sets its package logger to INFO: the root logger's WARNING level discarded its INFO records, such as a deferred budget-window year, before the observability runtime's handler saw them. `log_extra` keeps a field named like a LogRecord attribute only in `policyengine_attributes`, since `logging` raises for it. One `DatabaseTable` type in the shared module lists the tables telemetry names. Rule `sim.observability.log-fields-through-log-extra` registers the static check, and the observability guide's new section follows the identifier table instead of splitting it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ck reads, after review round 3 `PACKAGE_LOGGER_NAME` comes from the module name, and the INFO-level test imports it. The guide and the rule's statement say the check reads only field names written as keywords in `log_extra(...)`, and that a field named like a LogRecord attribute goes only to `policyengine_attributes`. The budget-window log test checks the started years' value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 17, 2026
…rd IDs branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…emetry record IDs branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d IDs branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g main #1090 added `household_job_outcome_unknown`, which built `policyengine_attributes` by hand; the rule this branch adds requires `log_extra`. The emitted fields don't change. Its docstring now gives the current reason it names no job. The text this branch added says API v1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With #1090 merged, 31 of the Entrypoint's 34 log calls that pass fields were affected, and only the calls about a row name one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
marked this pull request as ready for review
November 18, 2026 22:34
anth-volk
added a commit
that referenced
this pull request
Nov 18, 2026
GitHub moved this pull request's base to main without a push, which starts no PR checks run. This commit starts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
added a commit
that referenced
this pull request
Nov 19, 2026
The three logs of a cliff calculation's call now reach Cloud Logging, with the error's type and the cliff_impacts row, as #1092's rule requires of every Simulation Entrypoint log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1091
Each v2 Modal function's telemetry operation now names the API v1 row its call works on and its own Modal call. An operation that Modal interrupted in production then leads straight to its row.
New operation attributes
database_tabledatabase_row_idfrommodal_call_idrun_single_simulation_us,run_single_simulation_uksimulation_runscontext["simulation_run_id"]run_single_simulation_segment_ussimulation_runssimulation_run_id, which the US worker passes to each segment it startscoordinate_report(budget-window years included)report_runscontext["report_run"]["report_run_id"]calculate_household_us,calculate_household_ukwithhousehold_job_idhousehold_jobshousehold_job_idhousehold_report_run_idreport_runs(a household report run is areport_runsrow)household_report_run_idA call that works on no detailed-save row (a comparison-path call, a standalone simulation, a release validation's household calculation) names only
modal_call_id. Only a well-formed UUID is named: a malformed ID is left out, and the function refuses it as before.Why these names. The observability package (
policyengine-observability3.0.7) drops every attribute whose key containshousehold,reform,payloadorperson, among others, sohousehold_job_idwould never reach a log.job_idis reserved for one annual v1 Modal invocation, and the Simulation Entrypoint already logsrecord/record_idwith other values. One table-and-row pair works for every function, and the observability guide's identifier table now lists all three names.Off metrics. The IDs go to the operation's log records and span. Operation metrics carry only the service, the operation name and kind, and the outcome, under the package's metric allow list, which names none of these keys. A test reads the filtered metric attributes to confirm this.
The Simulation Entrypoint's log fields
The observability package's log handler emits only a log record's
policyengine_attributes; any other key passed inextra=stays on the PythonLogRecord. 31 of the Entrypoint's 34 log calls that pass fields passed them only that way, so their records in Cloud Logging carried the event name and no fields: no household job, report, run or error type. A key such ashousehold_job_idwould also have been dropped by the key filter above.log_extra(**fields)inpolicyengine_simulation_observability.log_recordsputs each field in both places, and every Entrypoint log call that passes fields uses it, includinghousehold_job_outcome_unknown, which Answer 500 when a household job's commit is unconfirmed, and move sim's database code to the SQLAlchemy ORM #1090 added. A field named like aLogRecordattribute goes only topolicyengine_attributes, sinceloggingraises for it.database_tableanddatabase_row_id, throughdatabase_row_attributes(table, row_id)and oneDatabaseTabletype shared with the v2 Modal functions:database_tablehousehold_call_unconfirmed,household_job_not_failed,household_job_not_read,household_call_not_recordedhousehold_job_idhousehold_jobshousehold_report_call_unconfirmed,household_report_call_not_recorded,household_report_run_not_failedreport_idreportseconomy_call_unconfirmed,economy_run_not_failed,economy_call_not_recordedrecord,record_idreportsorsimulationsbudget_window_not_started,budget_window_call_unconfirmedrecord,record_idreportsbudget_window_year_deferredrecord_id(a report run)report_runsbudget_window_call_unconfirmed'sstarted_yearsis joined into one string, since the runtime drops lists.budget_window_year_deferred,invalid_simulation_entry_bearer_token) before the handler saw them.sim.observability.log-fields-through-log-extra, enforced bytests/test_log_fields.py, which checks that every Entrypoint log call withextra=useslog_extraand that no field name written as a keyword contains a word the package drops. It has proof fixtures, anddocs/generated/rules.mdandAGENTS.mdare rendered again.How H7 · 1 can query them
Cloud Logging, project
policyengine-observability, logpolicyengine-api-v1-modal:Each matching record's
jsonPayload.attributes.database_tableandjsonPayload.attributes.database_row_idname the row; read its final status from that table.jsonPayload.attributes.modal_call_idis the interrupted call, whichreport_runs,simulation_runsandhousehold_jobsrecord as the call that claimed the row. A segment's call is recorded nowhere: its row is the simulation run that its simulation worker's call claimed.Notes
budget_window_schedulingused moved intostage12_runtime/operation_records.py, unchanged, so the coordinator and the window scheduler share it.src/modal/app.pyand its modules) imports nothing added here. No image contents, secrets or environment variables change.extra=fields, which are not emitted: three instage12_runtime/comparison.py, one instage12_runtime/coordinated_simulations.py, one in the contract library'sbudget_window_state.py, and the shared library'serrors.pyused by the v1 gateway.Tests
Test-first: c772f0c, deb60fa and b8eb69e add the failing tests. Only the new and affected tests were run, by node ID.
operation.completedrecord, after the package's filter, carries the three attributes, and that the metric attributes don't. They also check a call naming no row, a malformed ID, the US worker passing its run to its segments, and the segment runner's spawn keyword.Read-only review rounds: one on the v2 operations (no bugs); then three on the log fields. The first of those found that INFO records were never emitted, fixed test-first; the last found no bugs. A further round on the merge of
mainwith #1090 and the ORM conversion also found no bugs. Quality findings from every round are fixed.🤖 Generated with Claude Code