Procházet zdrojové kódy

Merge pull request #29117 from overleaf/jpa-clsi-logging

[clsi] log high level details for large clsi-cache requests

GitOrigin-RevId: e368d745554c925a665f8794514cc8bfed78b7b3
Eric Mc Sween před 10 měsíci
rodič
revize
4d39899e7b
1 změnil soubory, kde provedl 25 přidání a 5 odebrání
  1. 25 5
      services/clsi/app/js/CLSICacheHandler.js

+ 25 - 5
services/clsi/app/js/CLSICacheHandler.js

@@ -62,10 +62,8 @@ function notifyCLSICacheAboutBuild({
    * @param {[{path: string}]} files
    */
   const enqueue = files => {
-    Metrics.count('clsi_cache_enqueue_files', files.length)
-    fetchNothing(`${url}/enqueue`, {
-      method: 'POST',
-      json: {
+    const body = Buffer.from(
+      JSON.stringify({
         projectId,
         userId,
         buildId,
@@ -75,7 +73,29 @@ function notifyCLSICacheAboutBuild({
         clsiServerId: Settings.apis.clsi.clsiServerId,
         compileGroup,
         options,
-      },
+      })
+    )
+    const bodySize = body.byteLength
+    if (bodySize > 10_000_000) {
+      const outputPDF = files.find(f => f.path === 'output.pdf')
+      logger.warn(
+        {
+          projectId,
+          userId,
+          bodySize,
+          nFiles: files.length,
+          outputPDFSize:
+            outputPDF && Buffer.from(JSON.stringify(outputPDF)).byteLength,
+          nPDFCachingRanges: outputPDF?.ranges?.length,
+        },
+        'large clsi-cache request'
+      )
+    }
+    Metrics.count('clsi_cache_enqueue_files', files.length)
+    fetchNothing(`${url}/enqueue`, {
+      method: 'POST',
+      body,
+      headers: { 'Content-Type': 'application/json' },
       signal: AbortSignal.timeout(15_000),
     }).catch(err => {
       logger.warn(