-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Feature Request: http.client.request.created Event in diagnostics_channel #55352
Comments
To trace the outgoing requests you can create a custom wrapper right around the request function? |
While creating a custom wrapper around the request function could work for tracing outgoing requests, it requires the user to modify their code to use the wrapper, which contradicts the goal of the library. The intention of the library is to function seamlessly without requiring users to add custom code or monkey-patch their environment. Additionally, users may utilize different HTTP clients (e.g., |
PR-URL: #55586 Fixes: #55352 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: theanarkh <[email protected]>
PR-URL: nodejs#55586 Fixes: nodejs#55352 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: theanarkh <[email protected]>
PR-URL: nodejs#55586 Fixes: nodejs#55352 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: theanarkh <[email protected]>
PR-URL: #55586 Fixes: #55352 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: theanarkh <[email protected]>
PR-URL: #55586 Fixes: #55352 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: theanarkh <[email protected]>
PR-URL: #55586 Fixes: #55352 Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Jake Yuesong Li <[email protected]> Reviewed-By: theanarkh <[email protected]>
What is the problem this feature will solve?
I am developing a library to trace HTTP server requests. The goal is to track requests from initiation to completion, including server-to-server (outgoing) requests.
Using
diagnostics_channel
andasync_hooks
, I have successfully implemented most of the tracking, except for extracting the body of outgoing server-to-server requests. The challenge arises because the only channel available to trace these requests,http.client.request.start
, is triggered after the request body has been written.Example
Here’s a typical server-to-server request scenario:
I need a way to trace outgoing requests before the body is written. Currently, the callback for
http.client.request.start
fires only after the body has been sent, which makes it impossible to capture the body at the right time.What is the feature you are proposing to solve the problem?
The feature I would like to suggest is to add a new
diagnostics_channel
event that is triggered when the request object is created, before the body is written, such as:http.client.request.created
This would allow developers to hook into the HTTP client request lifecycle earlier, making it possible to trace the request body and other parameters at the time of request creation.
What alternatives have you considered?
I tried different approaches to take the request body, but without success. The library should work without inspector and without adding command line options to the nodejs runtime, for that reason I discarded monkey patching using
import-in-the-middle
andrequire-in-the-middle
.Rejected Approaches
import-in-the-middle
orrequire-in-the-middle
was considered, but I want the library to work without modifying the Node.js runtime or requiring command-line options.If there are other approaches or best practices that would achieve this goal without relying on runtime modifications, I am open to exploring them.
Thank you for taking the time to read and consider this request.
The text was updated successfully, but these errors were encountered: