ampproject / amp-toolbox

A collection of AMP tools making it easier to publish and host AMP pages.
Apache License 2.0
449 stars 243 forks source link

feat: add monitoring to the docker image #1240

Closed mathieu-pousse closed 3 years ago

mathieu-pousse commented 3 years ago

As we are now using this docker image in prod, we needed to add some monitoring to understand the overall performances of the project.

Here is the result of what is running in prod for us.

We are able to produce such dashboard to ensure everything is running fine and set alerting on it. This also helps us to see the most time consuming transformation was the SeparateKeyframes that was useless for us and lead me to the previous MR :smile:

image

BTW, as we are running in k8s, the fact of having metrics exposed will help us to configure an HorizontalPodAutoscaler based on those metrics.

My main concern is about the refactoring I did of the profiling in the project and the way to write the doProfile method. Let me know.

Hope it helps

mathieu-pousse commented 3 years ago

I pushed the fixes

I am wondering how does the CI build the image.

Will it firstly build the new version of @ampproject/toolbox-optimizer then build the image that will pull the freshly created new bundle ?

samouri commented 3 years ago

I am wondering how does the CI build the image.

We actually don't have a good system for this yet. Right now we manually build + push new images. I'll create an issue to integrate image build/release with CD.

mathieu-pousse commented 3 years ago

Did I broke the CI with my PR ? Let me know

sebastianbenz commented 3 years ago

Noticed one problem that was causing the optimizer tests to fail.

sebastianbenz commented 3 years ago

And there seems to be another problem that jest fails to init optimizer-docker/metrics.js. One simple fix is to ignore the optimizer-docker dir during tests by adding this to jest.config.js:

   // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
-  // testPathIgnorePatterns: [
-  //   "/node_modules/"
-  // ],
+   testPathIgnorePatterns: [
+     "/node_modules/",
+     "<rootDir>/packages/optimizer-docker"
+   ],
mathieu-pousse commented 3 years ago

:tada: