jenkins-bot has submitted this change and it was merged.
Change subject: Improve ApiRequest logging
......................................................................
Improve ApiRequest logging
* Introduce apirequest trace channel
* Log request options instead of this.toString(), the latter just gives
"[object Object]".
* Introduce a request serial number for log correlation, since queueKey
can be very long.
Change-Id: Ied1a598fca8c07a00a409a2aa184fcd6de68f879
---
M lib/ParsoidLogger.js
M lib/mediawiki.ApiRequest.js
M lib/mediawiki.Util.js
3 files changed, 14 insertions(+), 1 deletion(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/ParsoidLogger.js b/lib/ParsoidLogger.js
index d7dc9af..25f4974 100644
--- a/lib/ParsoidLogger.js
+++ b/lib/ParsoidLogger.js
@@ -156,6 +156,7 @@
"trace/domdiff": "[DOM-DIFF]",
"trace/wt-escape": "[wt-esc]",
"trace/batcher": "[batcher]",
+ "trace/apirequest": "[ApiRequest]",
};
ParsoidLogger.prototype._defaultTracerBackend = function(logData, cb) {
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index 4476ec9..93dfb21 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -19,6 +19,8 @@
var util = require('util');
var domino = require('domino');
+var latestSerial = 0;
+
// all revision properties which parsoid is interested in.
var PARSOID_RVPROP =
('content|ids|timestamp|user|userid|size|sha1|contentmodel|comment');
@@ -212,6 +214,7 @@
this.env = env;
this.title = title;
this.queueKey = title;
+ this.serial = ++latestSerial;
this.reqType = "Page Fetch";
// Proxy to the MW API. Set to null for subclasses going somewhere else.
@@ -258,7 +261,8 @@
options.headers['X-Forwarded-Proto'] = 'https';
}
}
- this.env.dp("Starting HTTP request", this.toString());
+ this.env.dp("Starting HTTP request: ", options);
+ this.trace(options);
return request(options, callback);
};
@@ -325,6 +329,7 @@
var self = this;
if (error) {
+ this.trace("Received error:", error);
this.env.log('warning/api' + (error.code ? ("/" +
error.code).toLowerCase() : ''),
'Failed API request,', {
"error": error,
@@ -344,8 +349,10 @@
this._handleBody(dnee, '{}');
}
} else if (response.statusCode === 200) {
+ this.trace("Received HTTP 200, ", body.length, "bytes");
this._handleBody(null, body);
} else {
+ this.trace("Received HTTP", response.statusCode, ": ", body);
if (response.statusCode === 412) {
this.env.log("info", "Cache MISS:",
response.request.href);
} else {
@@ -391,6 +398,10 @@
this._handleJSON(error, data);
};
+ApiRequest.prototype.trace = function() {
+ this.env.log.apply(null, ["trace/apirequest", "#" +
this.serial].concat(Array.prototype.slice.call(arguments)));
+};
+
/**
* @class
* @extends ApiRequest
diff --git a/lib/mediawiki.Util.js b/lib/mediawiki.Util.js
index f210223..4c0bfc3 100644
--- a/lib/mediawiki.Util.js
+++ b/lib/mediawiki.Util.js
@@ -134,6 +134,7 @@
" * domdiff : trace actions of the DOM diffing code",
" * wt-escape : debug wikitext-escaping",
" * batcher : trace API batch aggregation and
dispatch",
+ " * apirequest: trace all API requests",
"",
"--debug enables tracing of all the above phases except
Token Transform Managers",
"",
--
To view, visit https://gerrit.wikimedia.org/r/245604
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied1a598fca8c07a00a409a2aa184fcd6de68f879
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits