如何在 App Engine 标准环境 (Node.js) 中设置 Google Cloud Error Reporting?
How to setup Google Cloud Error Reporting in App Engine standard environment (Node.js)?
在 docs 它说
Note: Error logs written to stderr are processed automatically by Error Reporting, without needing to use the Error Reporting library for Node.js directly.
因此,我的应用程序(Node.js 14,App Engine 标准环境)将错误记录到 stderr
,我可以在 Google 云日志仪表板中看到它们。
// Error Object
{
"insertId": "60b9efa000007121b8631531",
"jsonPayload": {
"type": "Error",
"pid": 10,
"level": 50,
"stack": "Error: test\n at Object.<anonymous> (/workspace/dist/utils/logger.js:39:22)\n at Module._compile (internal/modules/cjs/loader.js:1068:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)\n at Module.load (internal/modules/cjs/loader.js:933:32)\n at Function.Module._load (internal/modules/cjs/loader.js:774:14)\n at Module.require (internal/modules/cjs/loader.js:957:19)\n at require (internal/modules/cjs/helpers.js:88:18)\n at Object.<anonymous> (/workspace/dist/routes/product-category/edit.js:8:18)\n at Module._compile (internal/modules/cjs/loader.js:1068:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)",
"message": "o noo",
"time": 1622798240028,
"hostname": "localhost"
},
"resource": {
"type": "gae_app",
"labels": {
"project_id": "xxx",
"zone": "us17",
"module_id": "default",
"version_id": "20210604t091336"
}
},
"timestamp": "2021-06-04T09:17:20.028961Z",
"severity": "ERROR",
"labels": {
"clone_id": "00c61b117c4c0ddc91320383c7a1462a90cff4d4f94ba3ec8a2e77217475dd58d4a633941d95a17ff0c2889faffc45f43561f51fad7d5a16bd1e38a1fba05e65fc70fdd43ec7"
},
"logName": "projects/xxx/logs/stderr",
"receiveTimestamp": "2021-06-04T09:17:20.046939477Z"
}
但这在 Google Cloud Error Reporting dashboard (dashboard) 中没有被报道。
我认为 App Engine stderr
会被 Error Reporter 自动使用。
您提到的 comment 在 'App Engine Flexible Environment' 的部分下并且您在 App Engine Standard Env 中工作。该文档说 - 您可以在以下 Google 云环境中为 Node.js 配置错误报告 - 并且未列出 App Engine 标准。因此,标准可能不支持 API,或者您必须为标准
显式配置它
在 docs 它说
Note: Error logs written to stderr are processed automatically by Error Reporting, without needing to use the Error Reporting library for Node.js directly.
因此,我的应用程序(Node.js 14,App Engine 标准环境)将错误记录到 stderr
,我可以在 Google 云日志仪表板中看到它们。
// Error Object
{
"insertId": "60b9efa000007121b8631531",
"jsonPayload": {
"type": "Error",
"pid": 10,
"level": 50,
"stack": "Error: test\n at Object.<anonymous> (/workspace/dist/utils/logger.js:39:22)\n at Module._compile (internal/modules/cjs/loader.js:1068:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)\n at Module.load (internal/modules/cjs/loader.js:933:32)\n at Function.Module._load (internal/modules/cjs/loader.js:774:14)\n at Module.require (internal/modules/cjs/loader.js:957:19)\n at require (internal/modules/cjs/helpers.js:88:18)\n at Object.<anonymous> (/workspace/dist/routes/product-category/edit.js:8:18)\n at Module._compile (internal/modules/cjs/loader.js:1068:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)",
"message": "o noo",
"time": 1622798240028,
"hostname": "localhost"
},
"resource": {
"type": "gae_app",
"labels": {
"project_id": "xxx",
"zone": "us17",
"module_id": "default",
"version_id": "20210604t091336"
}
},
"timestamp": "2021-06-04T09:17:20.028961Z",
"severity": "ERROR",
"labels": {
"clone_id": "00c61b117c4c0ddc91320383c7a1462a90cff4d4f94ba3ec8a2e77217475dd58d4a633941d95a17ff0c2889faffc45f43561f51fad7d5a16bd1e38a1fba05e65fc70fdd43ec7"
},
"logName": "projects/xxx/logs/stderr",
"receiveTimestamp": "2021-06-04T09:17:20.046939477Z"
}
但这在 Google Cloud Error Reporting dashboard (dashboard) 中没有被报道。
我认为 App Engine stderr
会被 Error Reporter 自动使用。
您提到的 comment 在 'App Engine Flexible Environment' 的部分下并且您在 App Engine Standard Env 中工作。该文档说 - 您可以在以下 Google 云环境中为 Node.js 配置错误报告 - 并且未列出 App Engine 标准。因此,标准可能不支持 API,或者您必须为标准
显式配置它