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