nodejs / nodejs/undici

diagnostic channel events on body consume / cancel

Open
#1,173 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
7.7k
Forks
880
Avg merge
2d 16h
Merged PRs (30d)
68

Description

Discussed in https://github.com/nodejs/undici/discussions/1170

Originally posted by artur-ma January 19, 2022
Following this https://github.com/DataDog/dd-trace-js/pull/1642#issuecomment-1009298056
Looks like to have full visibility and have good APM instrumentation, the APM agent should know when the request actually finished, including reading the body from the socket.

Do you have any thoughts or ideas on what is the right way to implement it?

AFAIK the body object always be consumed or cancelled according to the docs, so the right direction to look on is the Readable object

Specifically these parts:

https://github.com/nodejs/undici/blob/main/lib/api/readable.js#L41-L56 - Destroy
https://github.com/nodejs/undici/blob/main/lib/api/readable.js#L266-L283 - ConsumeFinish

IMO just sending an event from "ConsumeFinish" is not enough since it will need some reference on the request itself to be able to finish the right span which currently is missing on Readable

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked discussion and the referenced sections of lib/api/readable.js, especially Destroy and ConsumeFinish, then inspect how the request and body are connected. The issue does not define an event shape or acceptance criteria; completion would require agreeing on how diagnostic events identify the request and cover body consumption or cancellation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.