mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #5691 from overleaf/em-logger
More GCP logging improvements GitOrigin-RevId: 6049567c5d713582551b58169c019596fc68493e
This commit is contained in:
parent
4ed8e1d7d1
commit
7d8c1397be
5 changed files with 1986 additions and 147 deletions
|
@ -37,12 +37,23 @@ function convertLogEntry(entry) {
|
|||
}
|
||||
if (entry.err.stack) {
|
||||
gcpEntry.message = entry.err.stack
|
||||
} else if (entry.err.message) {
|
||||
gcpEntry.message = entry.err.message
|
||||
}
|
||||
if (entry.name) {
|
||||
gcpEntry.serviceContext = { service: entry.name }
|
||||
}
|
||||
} else {
|
||||
gcpEntry.message = entry.msg
|
||||
}
|
||||
|
||||
// Log message
|
||||
if (entry.msg) {
|
||||
if (gcpEntry.message) {
|
||||
// A message has already been extracted from the error. Keep the extra
|
||||
// message in the msg property.
|
||||
gcpEntry.msg = entry.msg
|
||||
} else {
|
||||
gcpEntry.message = entry.msg
|
||||
}
|
||||
}
|
||||
|
||||
// Severity
|
||||
|
@ -85,9 +96,14 @@ function convertLogEntry(entry) {
|
|||
}
|
||||
|
||||
// Labels are indexed in GCP. We copy the project, doc and user ids to labels to enable fast filtering
|
||||
const projectId = gcpEntry.projectId || gcpEntry.project_id
|
||||
const userId = gcpEntry.userId || gcpEntry.user_id
|
||||
const docId = gcpEntry.docId || gcpEntry.doc_id
|
||||
const projectId =
|
||||
gcpEntry.projectId ||
|
||||
gcpEntry.project_id ||
|
||||
(entry.req && entry.req.projectId)
|
||||
const userId =
|
||||
gcpEntry.userId || gcpEntry.user_id || (entry.req && entry.req.userId)
|
||||
const docId =
|
||||
gcpEntry.docId || gcpEntry.doc_id || (entry.req && entry.req.docId)
|
||||
if (projectId || userId || docId) {
|
||||
const labels = {}
|
||||
if (projectId) {
|
||||
|
|
2085
libraries/logger/package-lock.json
generated
2085
libraries/logger/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@
|
|||
"url": "https://github.com/overleaf/overleaf"
|
||||
},
|
||||
"license": "AGPL-3.0-only",
|
||||
"version": "3.0.0",
|
||||
"version": "3.1.0",
|
||||
"scripts": {
|
||||
"test": "mocha --grep=$MOCHA_GREP test/**/*.js",
|
||||
"format": "prettier-eslint $PWD'/**/*.js' --list-different",
|
||||
|
@ -17,7 +17,6 @@
|
|||
"test:ci": "npm run test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@google-cloud/logging-bunyan": "^3.1.0",
|
||||
"@overleaf/o-error": "^3.0.0",
|
||||
"@sentry/node": "^6.13.2",
|
||||
"bunyan": "^1.8.14",
|
||||
|
|
|
@ -7,7 +7,7 @@ function errSerializer(err) {
|
|||
return {
|
||||
message: err.message,
|
||||
name: err.name,
|
||||
stack: OError.getFullStack(err),
|
||||
stack: err.stack && OError.getFullStack(err),
|
||||
info: OError.getFullInfo(err),
|
||||
code: err.code,
|
||||
signal: err.signal
|
||||
|
@ -19,7 +19,7 @@ function reqSerializer(req) {
|
|||
return req
|
||||
}
|
||||
const headers = req.headers || {}
|
||||
return {
|
||||
const entry = {
|
||||
method: req.method,
|
||||
url: req.originalUrl || req.url,
|
||||
remoteAddress: getRemoteIp(req),
|
||||
|
@ -29,6 +29,20 @@ function reqSerializer(req) {
|
|||
'content-length': headers['content-length']
|
||||
}
|
||||
}
|
||||
const projectId =
|
||||
req.params.projectId || req.params.project_id || req.params.Project_id
|
||||
const userId = req.params.userId || req.params.user_id
|
||||
const docId = req.params.docId || req.params.doc_id
|
||||
if (projectId) {
|
||||
entry.projectId = projectId
|
||||
}
|
||||
if (userId) {
|
||||
entry.userId = userId
|
||||
}
|
||||
if (docId) {
|
||||
entry.docId = docId
|
||||
}
|
||||
return entry
|
||||
}
|
||||
|
||||
function resSerializer(res) {
|
||||
|
|
|
@ -50,7 +50,6 @@ describe('LoggingManager', function () {
|
|||
this.LoggingManager = SandboxedModule.require(MODULE_PATH, {
|
||||
requires: {
|
||||
bunyan: this.Bunyan,
|
||||
'@google-cloud/logging-bunyan': this.GCPLogging,
|
||||
'./log-level-checker': this.LogLevelChecker,
|
||||
'./sentry-manager': sinon.stub().returns(this.SentryManager)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue