ApplicationInsights-node.js
ApplicationInsights-node.js copied to clipboard
auto- dependency collection doesn't work for `fetch` calls?
My app has some calls made through the Node http
library which are properly tracked as dependencies. But some calls use the Node 18 fetch
API, and these aren't tracked. I looked through the AutoCollection
code and I don't see anything to monkey-patch this API.
same here
Is this due to the new native fetch implementation rewritten with undici under the hood?
I tested this at work by creating a request handler that switches between the native fetch and node-fetch, and can also confirm that only the request done with node-fetch are auto collected and those done with native fetch are not collected at all.
As far as i can see the native fetch method (undici under the hood) does not expose any methods or hooks that allows app insights to hook into the calls made by the native fetch, like it does by sniffing http
and https
requests done via e.g. node-fetch.
An easy alternative is to just stick to and use the node-fetch
package for the time being.
Seems we're facing the same issue. We just migrated to node 18, removing node-fetch and switching to native fetch and found we've lost dependency tracking. Are there plans to support native fetch with auto collection?
Seems we're facing the same issue. We just migrated to node 18, removing node-fetch and switching to native fetch and found we've lost dependency tracking. Are there plans to support native fetch with auto collection?
Not sure where this is on the roadmap/timeline of the Application Insights team.
We switched to rather use the node-fetch
package on our side for all outgoing calls from the node app, and since it uses the underlying http and https libraries from nodejs here ApplicationInsights continues to work as is.
Otherwise you would need to make a custom telemetry provider for Application Inisghts and use a DiagnosticsChannel to track the requests.
Resources:
- https://github.com/nodejs/undici/discussions/1512
- https://undici.nodejs.org/#/docs/api/DiagnosticsChannel
Most likely, I'm having the same issue: https://github.com/Azure/azure-sdk-for-js/issues/24505