Merge pull request #2292 from overleaf/as-remove-crawler-logger

Remove unused crawler logger and profile/heapdump routes

GitOrigin-RevId: e731f9a0cf969481b26c8074beca86431187449b
This commit is contained in:
Eric Mc Sween 2019-10-28 10:05:45 -04:00 committed by sharelatex
parent bcda5a2946
commit ecab52d108
4 changed files with 25 additions and 141 deletions

View file

@ -1,23 +0,0 @@
// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const metrics = require('metrics-sharelatex')
module.exports = {
log(req) {
if (req.headers['user-agent'] != null) {
const userAgent = req.headers['user-agent'].toLowerCase()
if (userAgent.indexOf('google') !== -1) {
return metrics.inc('crawler.google')
} else if (userAgent.indexOf('facebook') !== -1) {
return metrics.inc('crawler.facebook')
} else if (userAgent.indexOf('bing') !== -1) {
return metrics.inc('crawler.bing')
}
}
}
}

View file

@ -3,7 +3,6 @@ const express = require('express')
const Settings = require('settings-sharelatex') const Settings = require('settings-sharelatex')
const logger = require('logger-sharelatex') const logger = require('logger-sharelatex')
const metrics = require('metrics-sharelatex') const metrics = require('metrics-sharelatex')
const crawlerLogger = require('./CrawlerLogger')
const expressLocals = require('./ExpressLocals') const expressLocals = require('./ExpressLocals')
const Validation = require('./Validation') const Validation = require('./Validation')
const Router = require('../router') const Router = require('../router')
@ -171,12 +170,6 @@ if (app.get('env') === 'production') {
app.enable('view cache') app.enable('view cache')
} }
app.use(function(req, res, next) {
metrics.inc('http-request')
crawlerLogger.log(req)
next()
})
webRouter.use(function(req, res, next) { webRouter.use(function(req, res, next) {
if (Settings.siteIsOpen) { if (Settings.siteIsOpen) {
next() next()
@ -211,28 +204,6 @@ webRouter.use(function(req, res, next) {
})(req, res, next) })(req, res, next)
}) })
const profiler = require('v8-profiler-node8')
privateApiRouter.get('/profile', function(req, res) {
const time = parseInt(req.query.time || '1000')
profiler.startProfiling('test')
setTimeout(function() {
const profile = profiler.stopProfiling('test')
res.json(profile)
}, time)
})
privateApiRouter.get('/heapdump', (req, res, next) =>
require('heapdump').writeSnapshot(
`/tmp/${Date.now()}.web.heapsnapshot`,
(err, filename) => {
if (err != null) {
return next(err)
}
res.send(filename)
}
)
)
logger.info('creating HTTP server'.yellow) logger.info('creating HTTP server'.yellow)
const server = require('http').createServer(app) const server = require('http').createServer(app)

View file

@ -2290,7 +2290,8 @@
"abbrev": { "abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
"dev": true
}, },
"abort-controller": { "abort-controller": {
"version": "3.0.0", "version": "3.0.0",
@ -5812,11 +5813,6 @@
"integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=", "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=",
"dev": true "dev": true
}, },
"detect-libc": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg=="
},
"detect-node": { "detect-node": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz", "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.0.4.tgz",
@ -8005,11 +8001,13 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -8022,15 +8020,18 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -8133,7 +8134,8 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true "bundled": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -8143,6 +8145,7 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -8155,17 +8158,20 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true "bundled": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.3.5", "version": "2.3.5",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.2", "safe-buffer": "^5.1.2",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -8182,6 +8188,7 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -8260,7 +8267,8 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -8270,6 +8278,7 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -8375,6 +8384,7 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -9249,11 +9259,6 @@
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
"integrity": "sha512-z/GDPjlRMNOa2XJiB4em8wJpuuBfrFOlYKTZxtpkdr1uPdibHI8rYA3MY0KDObpVyaes0e/aunid/t88ZI2EKA==" "integrity": "sha512-z/GDPjlRMNOa2XJiB4em8wJpuuBfrFOlYKTZxtpkdr1uPdibHI8rYA3MY0KDObpVyaes0e/aunid/t88ZI2EKA=="
}, },
"heapdump": {
"version": "0.3.9",
"resolved": "https://registry.npmjs.org/heapdump/-/heapdump-0.3.9.tgz",
"integrity": "sha512-649th4Srbi7rC058t47ocoFU61hZDcSW9PMLuUnJRi5DuXrVytKrRLzL4P2nwEoSjHb/lDzGrmIWQCTJH1/NtA=="
},
"helmet": { "helmet": {
"version": "3.10.0", "version": "3.10.0",
"resolved": "https://registry.npmjs.org/helmet/-/helmet-3.10.0.tgz", "resolved": "https://registry.npmjs.org/helmet/-/helmet-3.10.0.tgz",
@ -10093,7 +10098,8 @@
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
"dev": true
}, },
"inquirer": { "inquirer": {
"version": "3.3.0", "version": "3.3.0",
@ -13904,58 +13910,6 @@
} }
} }
}, },
"node-pre-gyp": {
"version": "0.11.0",
"resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz",
"integrity": "sha512-TwWAOZb0j7e9eGaf9esRx3ZcLaE5tQ2lvYy1pb5IAaG1a2e2Kv5Lms1Y4hpj+ciXJRofIxxlt5haeQ/2ANeE0Q==",
"requires": {
"detect-libc": "^1.0.2",
"mkdirp": "^0.5.1",
"needle": "^2.2.1",
"nopt": "^4.0.1",
"npm-packlist": "^1.1.6",
"npmlog": "^4.0.2",
"rc": "^1.2.7",
"rimraf": "^2.6.1",
"semver": "^5.3.0",
"tar": "^4"
},
"dependencies": {
"deep-extend": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="
},
"nopt": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz",
"integrity": "sha512-+5XZFpQZEY0cg5JaxLwGxDlKNKYxuXwGt8/Oi3UXm5/4ymrJve9d2CURituxv3rSrVCGZj4m1U1JlHTdcKt2Ng==",
"requires": {
"abbrev": "1",
"osenv": "^0.1.4"
}
},
"rc": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
"integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
"requires": {
"deep-extend": "^0.6.0",
"ini": "~1.3.0",
"minimist": "^1.2.0",
"strip-json-comments": "~2.0.1"
}
},
"rimraf": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz",
"integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==",
"requires": {
"glob": "^7.1.3"
}
}
}
},
"node-releases": { "node-releases": {
"version": "1.1.26", "version": "1.1.26",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.26.tgz", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.26.tgz",
@ -20428,22 +20382,6 @@
"integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==", "integrity": "sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w==",
"dev": true "dev": true
}, },
"v8-profiler-node8": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/v8-profiler-node8/-/v8-profiler-node8-6.0.1.tgz",
"integrity": "sha512-DD7L0c/2KeFFQxs20VaFPHq/CSintttW4YB+QJdJ5ZohxOegbsMCvnZKHRHVA9UZfVYqq6ZsLaywe74+3JpZjw==",
"requires": {
"nan": "^2.5.1",
"node-pre-gyp": "^0.11.0"
},
"dependencies": {
"nan": {
"version": "2.13.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz",
"integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw=="
}
}
},
"val-loader": { "val-loader": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/val-loader/-/val-loader-1.1.1.tgz", "resolved": "https://registry.npmjs.org/val-loader/-/val-loader-1.1.1.tgz",

View file

@ -62,7 +62,6 @@
"fs-extra": "^4.0.2", "fs-extra": "^4.0.2",
"fuse.js": "^3.0.0", "fuse.js": "^3.0.0",
"handlebars": "^4.0.11", "handlebars": "^4.0.11",
"heapdump": "^0.3.7",
"helmet": "^3.8.1", "helmet": "^3.8.1",
"http-proxy": "^1.8.1", "http-proxy": "^1.8.1",
"is-utf8": "^0.2.1", "is-utf8": "^0.2.1",
@ -116,7 +115,6 @@
"underscore": "1.6.0", "underscore": "1.6.0",
"url-parse": "^1.4.7", "url-parse": "^1.4.7",
"uuid": "^3.0.1", "uuid": "^3.0.1",
"v8-profiler-node8": "^6.0.1",
"valid-url": "^1.0.9", "valid-url": "^1.0.9",
"xml2js": "^0.4.22", "xml2js": "^0.4.22",
"xregexp": "^4.2.4", "xregexp": "^4.2.4",