microsoft / ApplicationInsights-node.js

Microsoft Application Insights SDK for Node.js
MIT License
320 stars 138 forks source link

Warning when calling trackDependency passing data that is not a URL: "The URL object is failed to create" #1171

Open michaellperry opened 11 months ago

michaellperry commented 11 months ago

When I call trackDependency and pass in a data string value but no target, an extra warning is logged. 'The URL object is failed to create.' The following stack trace is included:

  TypeError [ERR_INVALID_URL]: Invalid URL
      at __node_internal_captureLargerStackTrace (node:internal/errors:478:5)
      at new NodeError (node:internal/errors:387:5)
      at URL.onParseError (node:internal/url:565:9)
      at new URL (node:internal/url:641:5)
      at NodeClient.TelemetryClient.trackDependency (/home/site/wwwroot/node_modules/applicationinsights/Library/TelemetryClient.ts:135:36)

The message is unhelpful. If target is required, then the message should tell me to populate it. I can only infer the meaning of the message after analyzing this code:

https://github.com/microsoft/ApplicationInsights-node.js/blob/a79885cfe51e8900d98cfda7b99442353f9d3c80/Library/TelemetryClient.ts#L134C61-L134C61

harleyz commented 7 months ago

this saved me some time. thanks @michaellperry