Skip to content

Missing diagnostics channel http.client.request.error #635

Description

@dreamorosi

Hi, I am not sure if this is the right forum to ask this question, but I since Node.js diagnostics_channel seems to fall under this working group I got here.

As of today, according to the Node.js docs there are two HTTP built-in channels for client events: http.client.request.start and http.client.response.finish.

Looking at the Node.js http module implementation, and after some tests it appears that there might be a gap in the events.

Subscribers can get notified when a request starts and when a response arrives, but there seems to not be a channel to subscribe for when the request fails (i.e. in the event of a ECONNREFUSED).

I am experimenting with tracing requests made with the http and https modules without having to patch the modules directly (which would require a loader with ESM) and without this type of channel/event if the request is going to fail any span created on http.client.request.start will remain orphaned & opened.

The fetch module has similar channels, but also has a undici:request:error channel that can be used for this.

Is the lack of this channel for the built-in HTTP events intentional? Am I misinterpreting entirely why these channels are there in the first place?

Activity

  1. Flarna commented on May 2, 2024

    @Flarna
    Member

    I don't think it's intentional. There was simply noone to take the time to implement all these events.

  2. dreamorosi commented on May 2, 2024

    @dreamorosi
    Author

    Thank you for your reply.

    I'll spend some time understanding what would be the appropriate process to propose this, in the meanwhile I'd be interested - if possible - to hear how other APM vendors are approaching the problem of instrumenting http requests with ESM.

    I'm familiar with loader-based approaches like import-in-the-middle and I am wondering if there's any other approach that you have seen.

  3. Flarna commented on May 3, 2024

    @Flarna
    Member

    http is a built in module and not ESM so besides ESM customization hooks it should be also possible to use old style monkey patching.
    Clearly all this approach to monkey patch node internals, rewrite imported files, change import graph go hand in hand with risk.

  4. github-actions commented on Aug 2, 2024

    @github-actions

    This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

  5. dreamorosi commented on Aug 2, 2024

    @dreamorosi
    Author

    This seems to have landed in nodejs/node#54054 - we can close for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions