GWicke has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/259150

Change subject: Log more detail on some error responses
......................................................................

Log more detail on some error responses

We are currently trying to figure out the reason for the high rate of 4xx
responses recently, but don't have good information on the incoming requests.

This patch logs more detail on failed responses with a probability of 10%.

Change-Id: Ie2dbba72ebd59745463f30fdcb58ffcf4ce6944b
---
M routes/mathoid.js
1 file changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mathoid 
refs/changes/50/259150/1

diff --git a/routes/mathoid.js b/routes/mathoid.js
index f9faa92..9b95c82 100644
--- a/routes/mathoid.js
+++ b/routes/mathoid.js
@@ -50,7 +50,7 @@
         format + ": true\" to enable " + format + "rendering.");
 }
 
-function handleRequest(res, q, type, outFormat, features) {
+function handleRequest(res, q, type, outFormat, features, req) {
     var sanitizedTex;
     var svg = app.conf.svg && /^svg|json|complete$/.test(outFormat);
     var mml = (type !== "MathML") && /^mml|json|complete$/.test(outFormat);
@@ -65,6 +65,15 @@
             sanitizedTex = feedback.checked || '';
             q = sanitizedTex;
         } else {
+            // Log verbose datails of failed requests with a 10% chance
+            if (Math.random() > 0.1) {
+                feedback.request = {
+                    url: req.url,
+                    params: req.params,
+                    headers: req.headers,
+                    body: req.body,
+                };
+            }
             emitError(feedback.error.name + ': ' + feedback.error.message, 
feedback);
         }
         if (app.conf.texvcinfo && outFormat === "texvcinfo") {
@@ -201,7 +210,7 @@
     } else {
         outFormat = "json";
     }
-    handleRequest(res, q, type, outFormat, {speakText:speakText});
+    handleRequest(res, q, type, outFormat, {speakText:speakText}, req);
 
 });
 

-- 
To view, visit https://gerrit.wikimedia.org/r/259150
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie2dbba72ebd59745463f30fdcb58ffcf4ce6944b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mathoid
Gerrit-Branch: master
Gerrit-Owner: GWicke <gwi...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to