-
-
Notifications
You must be signed in to change notification settings - Fork 666
feat: add TracingChannel support for native APM instrumentation #4178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wellwelwel
merged 10 commits into
sidorares:master
from
logaretm:feat/tracing-channel-support
Mar 14, 2026
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
abea8f7
feat: add TracingChannel support for native APM instrumentation
logaretm 5c85365
fix: guard tracing wrappers on hasSubscribers, preserve this binding
logaretm b35f667
fix: exit tracing test early on Node 18 where TracingChannel is unava…
logaretm cd7d6f3
address reviewer feedback: use skip() instead of exit, export dc for …
logaretm 97ca3bb
fix hasSubscribers check for Node 18 TracingChannel backport
logaretm 2c338ff
refactor: extract shouldTrace helper for hasSubscribers checks
logaretm edc9360
switch from tracePromise to traceCallback for callback-based ops
logaretm 0d27946
add tracing channels documentation page
logaretm 14f2d53
docs: use 'no overhead' instead of 'zero overhead'
logaretm 9987d30
docs: fix prettier formatting for tracing channels page
logaretm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import type { TracingChannel } from 'node:diagnostics_channel'; | ||
|
|
||
| export interface QueryTraceContext { | ||
| query: string; | ||
| values: any; | ||
| database: string; | ||
| serverAddress: string; | ||
| serverPort: number | undefined; | ||
| } | ||
|
|
||
| export interface ExecuteTraceContext { | ||
| query: string; | ||
| values: any; | ||
| database: string; | ||
| serverAddress: string; | ||
| serverPort: number | undefined; | ||
| } | ||
|
|
||
| export interface ConnectTraceContext { | ||
| database: string; | ||
| serverAddress: string; | ||
| serverPort: number | undefined; | ||
| user: string; | ||
| } | ||
|
|
||
| export interface PoolConnectTraceContext { | ||
| database: string; | ||
| serverAddress: string; | ||
| serverPort: number | undefined; | ||
| } | ||
|
|
||
| export declare const queryChannel: | ||
| | TracingChannel<QueryTraceContext> | ||
| | undefined; | ||
| export declare const executeChannel: | ||
| | TracingChannel<ExecuteTraceContext> | ||
| | undefined; | ||
| export declare const connectChannel: | ||
| | TracingChannel<ConnectTraceContext> | ||
| | undefined; | ||
| export declare const poolConnectChannel: | ||
| | TracingChannel<PoolConnectTraceContext> | ||
| | undefined; | ||
|
|
||
| export declare function getServerContext(config: { | ||
| socketPath?: string; | ||
| host?: string; | ||
| port?: number; | ||
| }): { serverAddress: string; serverPort: number | undefined }; | ||
|
|
||
| export declare function traceQuery<T>( | ||
| fn: () => Promise<T>, | ||
| contextFactory: () => QueryTraceContext | ||
| ): Promise<T>; | ||
|
|
||
| export declare function traceExecute<T>( | ||
| fn: () => Promise<T>, | ||
| contextFactory: () => ExecuteTraceContext | ||
| ): Promise<T>; | ||
|
|
||
| export declare function traceConnect<T>( | ||
| fn: () => Promise<T>, | ||
| contextFactory: () => ConnectTraceContext | ||
| ): Promise<T>; | ||
|
|
||
| export declare function tracePoolConnect<T>( | ||
| fn: () => Promise<T>, | ||
| contextFactory: () => PoolConnectTraceContext | ||
| ): Promise<T>; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.