feat: add diagnostic channels for request lifecycle#7171
Open
OussemaNehdi wants to merge 1 commit intoexpressjs:masterfrom
Open
feat: add diagnostic channels for request lifecycle#7171OussemaNehdi wants to merge 1 commit intoexpressjs:masterfrom
OussemaNehdi wants to merge 1 commit intoexpressjs:masterfrom
Conversation
Add Node.js diagnostics_channel support for observing Express request processing. This enables APM tools, monitoring systems, and instrumentation libraries to hook into Express without monkey-patching. Channels added: - express.request.start — published before routing begins - express.request.finish — published when the response is fully sent - express.request.error — published on connection-level errors All channels use hasSubscribers guards so there is zero overhead when no diagnostic tool is listening. Closes expressjs#6353
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds
diagnostics_channelsupport for Express request lifecycle, as requestedin #6353. This enables APM and monitoring tools to observe request processing
without monkey-patching.
Channels
express.request.start{ req, res }express.request.finish{ req, res }express.request.error{ req, res, error }Design decisions
publish()call is guarded byhasSubscribers,so there is no performance cost when no diagnostic tool is listening
on-finishedfor completion tracking: Uses the existingon-finisheddependency (already used by
res.sendFile) to detect when the response isfully sent, covering all code paths including streaming and error responses
express.initializationchannel forapp startup. This PR covers the request lifecycle, which is the primary use
case for APM tools like OpenTelemetry and Datadog
Example usage