mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
[misc] fix module importing
This commit is contained in:
parent
b2e661b408
commit
6f4829e817
9 changed files with 10 additions and 10 deletions
|
@ -9,7 +9,7 @@ module.exports = (EventLoopMonitor = {
|
||||||
monitor(logger, interval, log_threshold) {
|
monitor(logger, interval, log_threshold) {
|
||||||
if (interval == null) { interval = 1000; }
|
if (interval == null) { interval = 1000; }
|
||||||
if (log_threshold == null) { log_threshold = 100; }
|
if (log_threshold == null) { log_threshold = 100; }
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
// check for logger on startup to avoid exceptions later if undefined
|
// check for logger on startup to avoid exceptions later if undefined
|
||||||
if ((logger == null)) { throw new Error("logger is undefined"); }
|
if ((logger == null)) { throw new Error("logger is undefined"); }
|
||||||
// monitor delay in setInterval to detect event loop blocking
|
// monitor delay in setInterval to detect event loop blocking
|
||||||
|
|
|
@ -11,7 +11,7 @@ const yn = require("yn");
|
||||||
const STACKDRIVER_LOGGING = yn(process.env['STACKDRIVER_LOGGING']);
|
const STACKDRIVER_LOGGING = yn(process.env['STACKDRIVER_LOGGING']);
|
||||||
|
|
||||||
module.exports.monitor = logger => (function(req, res, next) {
|
module.exports.monitor = logger => (function(req, res, next) {
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
const startTime = process.hrtime();
|
const startTime = process.hrtime();
|
||||||
const {
|
const {
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,13 +73,13 @@ module.exports = (MemoryMonitor = {
|
||||||
monitor(logger) {
|
monitor(logger) {
|
||||||
const interval = setInterval(() => MemoryMonitor.Check(logger)
|
const interval = setInterval(() => MemoryMonitor.Check(logger)
|
||||||
, oneMinute);
|
, oneMinute);
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
return Metrics.registerDestructor(() => clearInterval(interval));
|
return Metrics.registerDestructor(() => clearInterval(interval));
|
||||||
},
|
},
|
||||||
|
|
||||||
Check(logger) {
|
Check(logger) {
|
||||||
let mem;
|
let mem;
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
const memBeforeGc = (mem = inMegaBytes(process.memoryUsage()));
|
const memBeforeGc = (mem = inMegaBytes(process.memoryUsage()));
|
||||||
Metrics.gauge("memory.rss", mem.rss);
|
Metrics.gauge("memory.rss", mem.rss);
|
||||||
Metrics.gauge("memory.heaptotal", mem.heapTotal);
|
Metrics.gauge("memory.heaptotal", mem.heapTotal);
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
||||||
mongodbCore = require(v2_path);
|
mongodbCore = require(v2_path);
|
||||||
} catch (error1) {}
|
} catch (error1) {}
|
||||||
|
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
|
|
||||||
const monitorMethod = function(base, method, type) {
|
const monitorMethod = function(base, method, type) {
|
||||||
let _method;
|
let _method;
|
||||||
|
|
|
@ -19,13 +19,13 @@ module.exports = (OpenSocketsMonitor = {
|
||||||
monitor(logger) {
|
monitor(logger) {
|
||||||
const interval = setInterval(() => OpenSocketsMonitor.gaugeOpenSockets()
|
const interval = setInterval(() => OpenSocketsMonitor.gaugeOpenSockets()
|
||||||
, 5 * seconds);
|
, 5 * seconds);
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
return Metrics.registerDestructor(() => clearInterval(interval));
|
return Metrics.registerDestructor(() => clearInterval(interval));
|
||||||
},
|
},
|
||||||
|
|
||||||
gaugeOpenSockets() {
|
gaugeOpenSockets() {
|
||||||
let agents, hostname, url;
|
let agents, hostname, url;
|
||||||
const Metrics = require("./metrics");
|
const Metrics = require("./index");
|
||||||
const object = require('http').globalAgent.sockets;
|
const object = require('http').globalAgent.sockets;
|
||||||
for (url in object) {
|
for (url in object) {
|
||||||
agents = object[url];
|
agents = object[url];
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe('event_loop', function() {
|
||||||
warn: sinon.stub()
|
warn: sinon.stub()
|
||||||
};
|
};
|
||||||
return this.event_loop = SandboxedModule.require(modulePath, { requires: {
|
return this.event_loop = SandboxedModule.require(modulePath, { requires: {
|
||||||
'./metrics': this.metrics
|
'./index': this.metrics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,7 @@ describe('timeAsyncMethod', function() {
|
||||||
inc: sinon.stub()
|
inc: sinon.stub()
|
||||||
};
|
};
|
||||||
this.timeAsyncMethod = SandboxedModule.require(modulePath, { requires: {
|
this.timeAsyncMethod = SandboxedModule.require(modulePath, { requires: {
|
||||||
'./metrics': this.metrics
|
'./index': this.metrics
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
module.exports = function(obj, methodName, prefix, logger) {
|
module.exports = function(obj, methodName, prefix, logger) {
|
||||||
let modifedMethodName;
|
let modifedMethodName;
|
||||||
const metrics = require('./metrics');
|
const metrics = require('./index');
|
||||||
|
|
||||||
if (typeof obj[methodName] !== 'function') {
|
if (typeof obj[methodName] !== 'function') {
|
||||||
throw new Error(`[Metrics] expected object property '${methodName}' to be a function`);
|
throw new Error(`[Metrics] expected object property '${methodName}' to be a function`);
|
||||||
|
|
Loading…
Reference in a new issue