[web] Add startup metrics (#25277)

* [web] refactor startup sequence

The primary objective here is to call loadGlobalBlobs() only once.
But to get there, we need to reorder things and add extra try/catch
sections to ensure we are not letting the global uncaughtException
handler catch startup errors.

Co-authored-by: Antoine Clausse <antoine.clausse@overleaf.com>

* [web] add metrics for startup steps

Co-authored-by: Antoine Clausse <antoine.clausse@overleaf.com>

---------

Co-authored-by: Jakob Ackermann <jakob.ackermann@overleaf.com>
GitOrigin-RevId: c73edea02516e919d55b896588dcd1862835fedf
This commit is contained in:
Antoine Clausse
2025-05-06 16:18:14 +02:00
committed by Copybot
parent 531b03e808
commit 5b47fffcee
4 changed files with 69 additions and 35 deletions
@@ -4,6 +4,7 @@ const { promisify, callbackify } = require('util')
const Settings = require('@overleaf/settings')
const Views = require('./Views')
const _ = require('lodash')
const Metrics = require('@overleaf/metrics')
const MODULE_BASE_PATH = Path.join(__dirname, '/../../../modules')
@@ -15,7 +16,11 @@ let _viewIncludes = {}
async function modules() {
if (!_modulesLoaded) {
const beforeLoadModules = performance.now()
await loadModules()
Metrics.gauge('web_startup', performance.now() - beforeLoadModules, 1, {
path: 'loadModules',
})
}
return _modules
}