apm-agent-nodejs icon indicating copy to clipboard operation
apm-agent-nodejs copied to clipboard

instrument fetch()

Open trentm opened this issue 3 years ago • 1 comments

Node v18.0.0 (https://nodejs.org/en/blog/announcements/v18-release-announce/) brings a global fetch() implementation (https://nodejs.org/api/all.html#all_globals_fetch). Can we instrument that?

The node fetch() impl is, at least originally, based on undici, for which we have a separate issue: https://github.com/elastic/apm-agent-nodejs/issues/2383

trentm avatar Apr 20 '22 16:04 trentm

Node v18.0.0 also introduces experimental WebStreams support: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API

I'm not sure how necessarily tied together fetch() and web streams will be for our instrumentation. In particular the web streams docs talk about being able to cancel a fetch. Presumably just wrapping the Promise returned from fetch() is sufficient to instrument its completion, but I haven't grokked ReadableStream.cancel() yet.

trentm avatar Apr 20 '22 16:04 trentm

fetch() is now instrumented in [email protected] (release notes) by https://github.com/elastic/apm-agent-nodejs/issues/2383

trentm avatar Aug 16 '22 00:08 trentm