Skip to main content

Go Debugging and Observability

Attach runtime.NewSQLExecutionEvidenceStore() only to a trusted server context. The store retains parameters; use the generated Debug Assist's SafeSQLEvidenceFrom(...) projection before exposing diagnostics.

evidence := runtime.NewSQLExecutionEvidenceStore()
context.WithRuntimeTelemetrySink(evidence)
evidence.EnableQuery()

rows, err := lib.Q.Schools().
Comment("Diagnose the school search").
Purpose("Verify filters, facets, and relation loading").
ExecuteForList(context)
if err != nil { return err }

safe := SafeSQLEvidenceFrom(evidence.Snapshot())

Use EnableAll(), EnableQuery(), EnableMutation(), and Disable(); mode changes clear old entries. Select and mutation output can be disabled independently. The default stderr text sink is operator-only; remove it with WithDiagnosticSQLLogSink(nil).

Run the Facet, aggregate, deep relation, Top-N, and audited save examples from Go advanced data operations. Correlate trace, aliases, parameterized SQL, duration, result count, and affected rows while preserving native errors.

Install telemetry with context.WithRuntimeTelemetry(telemetry). Raw audit and the safe AppAuditEventSink remain separate. Go Request Policy currently covers select, insert, update, delete, and recover; run tenant-negative tests for all of them plus relations, Facets, aggregates, and federation. Use RuntimeReadiness() to verify trusted startup and provider reachability.

Finish with the shared checklist.