Skip to content

Add an optional query telemetry adapter - #343

Merged
elpete merged 3 commits into
mainfrom
feat/query-telemetry-adapter
Oct 25, 2026
Merged

elpete merged 3 commits into
mainfrom
feat/query-telemetry-adapter

Conversation

@elpete

@elpete elpete commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Add an optional QueryTelemetryAdapter@qb so qb owns its query execution listeners. Applications explicitly select it; qb does not require Sentry or install a telemetry client.

// Select the query adapter shipped by qb.
moduleSettings.sentry.queryAdapter = "QueryTelemetryAdapter@qb";

// Record this technical database system on the spans.
moduleSettings.sentry.databaseSystem = "postgresql";

configure(context) accepts a telemetry object and returns {mode:"custom",shutdown:callback}. The adapter skips pretend/manual observations, supports nested queries, restores the enclosing scope, and completes success/error spans once. Only scrubbed SQL and database-system metadata are passed to telemetry; bindings, options, results and exception contents stay out.

Each setup owns a unique registration. Shutdown rejects new observations and retains completion hooks until observed queries finish, then unregisters only that registration. A query that never completes can keep its completion hooks registered; shutdown does not cancel database calls.

The consumer configuration and removal of Sentry's qb-specific interceptor are in Sentry draft PR #56. Neither module adds a package dependency on the other.

Schema createView, createAs and alterView also use the module-qualified qb.models.Query.QueryBuilder constructor. The old webroot-relative models.Query.QueryBuilder path could load the same CFC under an alternate identity; on Adobe, running schema work first then rejected valid builders at a fully qualified typed boundary. The constructor correction preserves the original nominal argument/return checks and removes dependence on a consumer's webroot /models path.

Checks

  • Twelve adapter specs plus four existing failure-hook specs passed on each local Lucee 5.4.8.2, Adobe CF 2023 update 26 and BoxLang 1.18.0+66: 16 passed, zero failures/errors/skips.
  • Full qb suite on all three local engines: 3,438 passed, ten skipped, zero failures/errors (3,448 total). Adobe's full suite ran as the first request in a fresh JVM, without metadata/type-cache warm-up.
  • The schema regression reproduces the original Adobe rejection before the constructor correction: five typed-boundary errors in six tests. After the correction, all six pass; each of the three helpers also passes independently as the first executed test in its own fresh Adobe JVM. Tests retain SQL/binding assertions and reject invalid nominal arguments/returns. The identity fixtures bind explicit numeric 1 and assert exact 1, avoiding unrelated engine differences in boolean-to-bit normalization. The original retrievable wrapper and its existing spec are unchanged.
  • Companion Sentry checks passed 141/141 on each of Lucee, Adobe and BoxLang, including thirteen real PostgreSQL/cbq cases and actual WireBox discovery, query success/error/manual de-duplication, scope restoration, independent registrations and shutdown during ColdBox dispatch.
  • Independent CFML/BoxLang review caught the adapter shutdown race; it is fixed and re-reviewed. Local Adobe execution also caught a release() method-name collision with the generated page lifecycle; helpers use explicit execution names. The schema identity correction passed independent review too.
  • Seven affected CFCs were formatted; whitespace checks pass. Both push and PR hosted workflows passed on d846c4a; all 35 PR checks are green.

Configuration and adapter contract

@elpete
elpete marked this pull request as ready for review October 25, 2026 19:38
@elpete
elpete merged commit 7a94191 into main Oct 25, 2026
35 checks passed
@elpete
elpete deleted the feat/query-telemetry-adapter branch October 25, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant