mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-28 21:03:11 -05:00
Merge pull request #5181 from overleaf/bg-upgrade-sentry-package-version
Migrate from raven to @sentry/node GitOrigin-RevId: 1a82225b5204a9c507b566efff3c090b124e2392
This commit is contained in:
parent
603698ed32
commit
08e0dcb85f
4 changed files with 1802 additions and 1497 deletions
|
@ -72,9 +72,9 @@ const Logger = (module.exports = {
|
||||||
return res.text()
|
return res.text()
|
||||||
},
|
},
|
||||||
|
|
||||||
initializeErrorReporting(sentryDsn, options) {
|
initializeErrorReporting(dsn, options) {
|
||||||
const raven = require('raven')
|
this.Sentry = require('@sentry/node')
|
||||||
this.raven = new raven.Client(sentryDsn, options)
|
this.Sentry.init({ dsn, ...options })
|
||||||
this.lastErrorTimeStamp = 0 // for rate limiting on sentry reporting
|
this.lastErrorTimeStamp = 0 // for rate limiting on sentry reporting
|
||||||
this.lastErrorCount = 0
|
this.lastErrorCount = 0
|
||||||
},
|
},
|
||||||
|
@ -142,7 +142,7 @@ const Logger = (module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the error to sentry
|
// send the error to sentry
|
||||||
this.raven.captureException(error, { tags, extra, level })
|
this.Sentry.captureException(error, { tags, extra, level })
|
||||||
|
|
||||||
// put a flag on the errors to avoid reporting them multiple times
|
// put a flag on the errors to avoid reporting them multiple times
|
||||||
for (key in attributes) {
|
for (key in attributes) {
|
||||||
|
@ -152,7 +152,7 @@ const Logger = (module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// ignore Raven errors
|
// ignore Sentry errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -176,7 +176,7 @@ const Logger = (module.exports = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.logger.error(attributes, message, ...Array.from(args))
|
this.logger.error(attributes, message, ...Array.from(args))
|
||||||
if (this.raven != null) {
|
if (this.Sentry) {
|
||||||
const MAX_ERRORS = 5 // maximum number of errors in 1 minute
|
const MAX_ERRORS = 5 // maximum number of errors in 1 minute
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
// have we recently reported an error?
|
// have we recently reported an error?
|
||||||
|
@ -207,22 +207,10 @@ const Logger = (module.exports = {
|
||||||
return this.logger.warn.apply(this.logger, arguments)
|
return this.logger.warn.apply(this.logger, arguments)
|
||||||
},
|
},
|
||||||
|
|
||||||
fatal(attributes, message, callback) {
|
fatal(attributes, message) {
|
||||||
if (callback == null) {
|
|
||||||
callback = function () {}
|
|
||||||
}
|
|
||||||
this.logger.fatal(attributes, message)
|
this.logger.fatal(attributes, message)
|
||||||
if (this.raven != null) {
|
if (this.Sentry) {
|
||||||
var cb = function (e) {
|
|
||||||
// call the callback once after 'logged' or 'error' event
|
|
||||||
callback()
|
|
||||||
return (cb = function () {})
|
|
||||||
}
|
|
||||||
this.captureException(attributes, message, 'fatal')
|
this.captureException(attributes, message, 'fatal')
|
||||||
this.raven.once('logged', cb)
|
|
||||||
return this.raven.once('error', cb)
|
|
||||||
} else {
|
|
||||||
return callback()
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
3250
libraries/logger/package-lock.json
generated
3250
libraries/logger/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
||||||
"url": "http://github.com/sharelatex/logger-sharelatex.git"
|
"url": "http://github.com/sharelatex/logger-sharelatex.git"
|
||||||
},
|
},
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"version": "2.2.1",
|
"version": "2.3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --grep=$MOCHA_GREP test/**/*.js",
|
"test": "mocha --grep=$MOCHA_GREP test/**/*.js",
|
||||||
"format": "prettier-eslint $PWD'/**/*.js' --list-different",
|
"format": "prettier-eslint $PWD'/**/*.js' --list-different",
|
||||||
|
@ -18,9 +18,9 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@google-cloud/logging-bunyan": "^3.1.0",
|
"@google-cloud/logging-bunyan": "^3.1.0",
|
||||||
"@overleaf/o-error": "^3.0.0",
|
"@overleaf/o-error": "^3.0.0",
|
||||||
|
"@sentry/node": "^6.13.2",
|
||||||
"bunyan": "^1.8.14",
|
"bunyan": "^1.8.14",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"raven": "^2.6.4",
|
|
||||||
"yn": "^4.0.0"
|
"yn": "^4.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -25,9 +25,9 @@ describe('LoggingManager', function () {
|
||||||
level: sinon.stub(),
|
level: sinon.stub(),
|
||||||
warn: sinon.stub()
|
warn: sinon.stub()
|
||||||
}
|
}
|
||||||
this.ravenClient = {
|
this.Sentry = {
|
||||||
captureException: this.captureException,
|
init: sinon.stub(),
|
||||||
once: sinon.stub().yields()
|
captureException: this.captureException
|
||||||
}
|
}
|
||||||
this.fetchResponse = {
|
this.fetchResponse = {
|
||||||
text: sinon.stub().resolves(''),
|
text: sinon.stub().resolves(''),
|
||||||
|
@ -42,9 +42,6 @@ describe('LoggingManager', function () {
|
||||||
res: sinon.stub()
|
res: sinon.stub()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.Raven = {
|
|
||||||
Client: sinon.stub().returns(this.ravenClient)
|
|
||||||
}
|
|
||||||
this.Fetch = sinon.stub().resolves(this.fetchResponse)
|
this.Fetch = sinon.stub().resolves(this.fetchResponse)
|
||||||
this.Fs = {
|
this.Fs = {
|
||||||
readFile: sinon.stub(),
|
readFile: sinon.stub(),
|
||||||
|
@ -63,7 +60,7 @@ describe('LoggingManager', function () {
|
||||||
globals: { console, process },
|
globals: { console, process },
|
||||||
requires: {
|
requires: {
|
||||||
bunyan: this.Bunyan,
|
bunyan: this.Bunyan,
|
||||||
raven: this.Raven,
|
'@sentry/node': this.Sentry,
|
||||||
'node-fetch': this.Fetch,
|
'node-fetch': this.Fetch,
|
||||||
fs: this.Fs,
|
fs: this.Fs,
|
||||||
'@google-cloud/logging-bunyan': this.GCPLogging
|
'@google-cloud/logging-bunyan': this.GCPLogging
|
||||||
|
@ -452,7 +449,8 @@ describe('LoggingManager', function () {
|
||||||
this.fetchResponse.text = sinon
|
this.fetchResponse.text = sinon
|
||||||
.stub()
|
.stub()
|
||||||
.resolves((this.start + 1000).toString())
|
.resolves((this.start + 1000).toString())
|
||||||
this.logger.getTracingEndTime = this.logger.getTracingEndTimeMetadata
|
this.logger.getTracingEndTime =
|
||||||
|
this.logger.getTracingEndTimeMetadata
|
||||||
|
|
||||||
await this.logger.checkLogLevel()
|
await this.logger.checkLogLevel()
|
||||||
})
|
})
|
||||||
|
@ -471,7 +469,8 @@ describe('LoggingManager', function () {
|
||||||
.stub()
|
.stub()
|
||||||
.resolves((this.start + 1000).toString())
|
.resolves((this.start + 1000).toString())
|
||||||
this.Fetch.fetch = sinon.stub().resolves(this.fetchResponse)
|
this.Fetch.fetch = sinon.stub().resolves(this.fetchResponse)
|
||||||
this.logger.getTracingEndTime = this.logger.getTracingEndTimeMetadata
|
this.logger.getTracingEndTime =
|
||||||
|
this.logger.getTracingEndTimeMetadata
|
||||||
|
|
||||||
await this.logger.checkLogLevel()
|
await this.logger.checkLogLevel()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue