microsoft / ApplicationInsights-node.js

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

[Beta] Module size is too BIG #1240

Closed fakedob closed 2 months ago

fakedob commented 7 months ago

Hey guys, I have noticed that since I started using the beta, our dev environment, runing on Azure functions, started getting its cold start from 2 seconds, to 30+ seconds. Well, I didnt figured it out straight away and it did took me some time to realise that the new Beta depends on few node modules, specifically the @opentelemetry (as noted in the docs), that allocates around 36mb's os space. My package.json has only:

"dependencies": {
    "@azure/functions": "^4.0.1",
    "applicationinsights": "^3.0.0-beta.10"
  },

And my node_modules are already 69.5mb...

I understand this is still a beta, but are there any ways of reducing the package size, that you are aware? Are there plans to reduce the size, maybe distribute a compiled standalone version or other technique?

Thanks :)

paed01 commented 4 months ago

Thumbs up for this. Did some evaluation between patches v2.9.2 and v2.9.3 and the increase in size is exponential. Some dependencies should be optional at best.

v2.9.2

v2 9 2

v2.9.3

v2 9 3

One culprit seems to be the @nevware21 packages.

npm list @nevware21/ts-async
`-- applicationinsights@2.9.3
  `-- @microsoft/applicationinsights-web-snippet@1.1.0
    `-- @microsoft/applicationinsights-common@3.1.0
      `-- @microsoft/applicationinsights-core-js@3.1.0
        `-- @nevware21/ts-async@0.4.0

Considering the extremely slow releases of nodejs apps in Azure Dev Ops, correlating to the number of files, this is getting very annoying.

paed01 commented 4 months ago

Quite an increase: https://bundlephobia.com/package/applicationinsights@3.0.0-beta.11

https://bundlephobia.com/package/@azure/functions

MSNev commented 4 months ago

We have created the following Application Insights Issue to address the inclusion of these dependencies, as they are not actually needed at runtime, once we rework the inclusion we will publish an updated v1.1.1 version.

paed01 commented 4 months ago

Much better, now it is back to normal sizes.

v2.9.4

v2 9 4

Thank you.

@fakedob I scanned the directories with TreeSize free (Windows) after npm prune --omit=dev

JacksonWeber commented 2 months ago

Closing as the bundle sizes were reduced.