You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: extend TracingChannel coverage to the callback API
The callback branches of query/batch/execute/bulk on Request, prepare
and execute on PreparedStatement, and connect on ConnectionPool were
previously invisible to TracingChannel subscribers, forcing consumers
to migrate to the promise API just to get observability.
Add a traceCallback helper alongside tracePromise in lib/diagnostics
that wraps Node's TracingChannel#traceCallback with the same
hasSubscribers fast path. Route each callback branch through it so
subscribers see the same start / end / asyncStart / asyncEnd / error
sub-events regardless of which API style the caller chose — no
branching required on the subscriber side.
Internal requests (sp_prepare, sp_execute, sp_unprepare) continue to
be suppressed via _internal; Request exposes a _tracedCallback mirror
of _tracedPromise to keep that gate symmetric. Stream-mode
PreparedStatement.execute without a user callback falls through
untraced because there is no async boundary for traceCallback to hook
— streaming consumers get lifecycle via Request events instead.
Update the README note that said the promise API was the only traced
path.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2265,7 +2265,7 @@ TracingChannel contexts include identifiers (`requestId`, `poolId`), operation d
2265
2265
2266
2266
> **Note on identifiers:**`connectionId`, `poolId`, `requestId`, `transactionId`, and `preparedStatementId` are monotonically increasing integers scoped to the current node process. They are not stable across restarts and cannot be used to correlate activity across processes.
2267
2267
2268
-
> **Note:** TracingChannel instrumentation is active on the **promise** API. If you use the callback API, TracingChannelevents will not fire for those calls. Point-event channels (connection, transaction, pool lifecycle) fire regardless of API style.
2268
+
> **Note:** TracingChannel instrumentation fires for both the promise and callback APIs. The callback API is traced via Node's `TracingChannel#traceCallback`, which emits the same `start` / `end` / `asyncStart` / `asyncEnd` / `error` sub-events as the promise path, so subscribers do not need to branch by API style. Point-event channels (connection, transaction, pool lifecycle) likewise fire regardless of API style.
0 commit comments