Python Debugging and Observability
Collect SQL evidence only on a trusted, server-created UserContext. The
generated Debug Assist supplies a safe_sql_evidence(...) projection that
omits params and debug_sql.
context.enable_select_sql_log()
rows = await (
Q.schools()
.comment("Diagnose the school search")
.purpose("Verify filters, facets, and relation loading")
.execute_for_list(context)
)
safe = safe_sql_evidence(context.sql_logs())
Use enable_all_sql_log(), enable_select_sql_log(),
enable_mutation_sql_log(), and disable_sql_log(); mode changes clear old
entries. Select and mutation output can also be disabled independently. Use
with_diagnostic_sql_log_sink(TextDiagnosticSqlLogSink()) only for trusted
operator output.
Run the Facet, aggregate, deep relation, Top-N, and audited save examples from
Python advanced data operations. Correlate
trace_path, aliases, duration, result count, and affected rows. Preserve
native not-found, checker, conflict, and provider exceptions.
Install OpenTelemetry with context.with_runtime_telemetry(telemetry). Raw row
audit remains separate from the masked application audit sink. Python request
policy currently prepares queries; mutation tenant authorization must also be
enforced and tested at the application/provider/TFP boundary.
Finish with the shared checklist.