netlify / zip-it-and-ship-it

Intelligently prepare Node.js Lambda functions for deployment
https://www.npmjs.com/package/@netlify/zip-it-and-ship-it
MIT License
316 stars 35 forks source link

Compile metrics about bundling process #969

Open eduardoboucas opened 2 years ago

eduardoboucas commented 2 years ago

Netlify Build shows the duration of the functions bundling process, but we have no granular view that allows us to see where that time is spent across the various functions and the different stages of the process.

This capability would allow developers to identify (and potentially self-serve solutions for) offenders in a slow bundling process, and it would allow us to better troubleshoot problems like #968.

I propose a new metadata object to be returned by zipFunction and zipFunctions, containing a metrics array of tasks and their duration. Something like:

{
  "metadata": {
    "metrics": [
      {
        "function": "function-1",
        "stage": "discovery",
        "duration": 123
      },
      {
        "function": "function-1",
        "stage": "parsing",
        "duration": 234
      },
      {
        "function": "function-1",
        "stage": "isc",
        "duration": 345
      },
      {
        "function": "function-1",
        "stage": "traversing",
        "duration": 456
      },
      {
        "function": "function-1",
        "stage": "zipping",
        "duration": 567
      }
    ]
  }
}

Netlify Build could then print this object when the verbose mode is enabled.

ehmicky commented 2 years ago

Nice idea!