当我尝试向简单的 Node.js Express 服务器的 Sentry 发送错误时,Sentry 本身没有记录任何错误。没有设置入站过滤器,并且不会报告过去 30 天内过滤的任何内容。允许的域设置为*,我认为这是默认值。我使用的代码与文档中的示例代码或多或少相同。但是,当调用端点时,Sentry 中不会出现任何内容,并且调试行即使发送了错误也不会显示任何有关错误的信息。
如何让 Sentry 正确捕获错误?
这是测试.js
'use strict';
const express = require('express');
const Sentry = require('@sentry/node');
const app = express();
// TODO dotenv setting
const SENTRY_NODE_DSN = process.env.SENTRY_NODE_DSN || 'the ingest url from settings > client keys';
console.log(`Started logging errors at sentry on DSN ${SENTRY_NODE_DSN}`);
// Sentry
Sentry.init({
dsn: SENTRY_NODE_DSN,
debug: true,
});
// The request handler must be the first middleware on the app
app.use(Sentry.Handlers.requestHandler());
const port …Run Code Online (Sandbox Code Playgroud) 我们不使用Sentry的重播功能
它正在发送大量事件:
{"type":"replay_event"}
Run Code Online (Sandbox Code Playgroud)
似乎无法在管理设置中停用它。
关于如何通过 Sentry.init({}) 停用它有什么想法吗?
在 Node.js 8 中,如果我在代码末尾使用 process.exit(0) ,我将无法捕获哨兵上的错误。否则它工作正常
const Sentry = require('@sentry/node');
Sentry.init({ dsn: 'https://c3f5****************34dbf@sentry.io/1288850' });
try{
throw new Error('test-error');
}
catch(e){
const Eid = Sentry.captureException(e);
console.log(Eid);
}
process.exit(0);
Run Code Online (Sandbox Code Playgroud) 我对 Nestjs 中的这个包有疑问@ntegral/nestjs-sentry。我有一个在我的应用程序中使用的自定义记录器
@Injectable()\nexport class CustomLogger implements LoggerService {\n constructor(@InjectSentry() private readonly client: SentryService) {}\n\n log(message: any, ...optionalParams: any[]) {\n this.client.instance().captureMessage(message, ...optionalParams);\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n然后我将其注入到用户控制器和 user.controller.spec.ts 中
\ndescribe(\'UsersController\', () => {\n let controller: UsersController;\n\n beforeEach(async () => {\n const module: TestingModule = await Test.createTestingModule({\n controllers: [UsersController],\n providers: [\n CustomLogger,\n UsersService,\n SentryService,\n ],\n }).compile();\n\n controller = module.get<UsersController>(UsersController);\n });\n\n it(\'should be defined\', () => {\n expect(controller).toBeDefined();\n });\n});\n\nRun Code Online (Sandbox Code Playgroud)\n我收到这个错误
\n FAIL src/users/users.controller.spec.ts (9.449 s)\n \xe2\x97\x8f UsersController \xe2\x80\xba should …Run Code Online (Sandbox Code Playgroud) 当我在本地服务器上工作时(即http://127.0.0.1:8000/ ) ,我试图阻止 Sentry 将错误记录到我的 Sentry 仪表板。我希望哨兵将错误记录到仪表板的唯一时间是当我的代码投入生产时。我该怎么办?我在下面尝试过这个,但它不起作用:
if DEBUG == True
sentry_sdk.init(
dsn=os.environ.get('SENTRY_DSN', None),
integrations=[DjangoIntegration()],
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production.
traces_sample_rate=1.0,
# If you wish to associate users to errors (assuming you are using
# django.contrib.auth) you may enable sending PII data.
send_default_pii=True
)
Run Code Online (Sandbox Code Playgroud) [!] CocoaPods 找不到 pod“Sentry”的兼容版本:在 Podfile 中:sentry_flutter(来自.symlinks/plugins/sentry_flutter/ios)已解析为 0.0.1,这取决于 Sentry (~> 7.11.0)
None of your spec sources contain a spec satisfying the dependency: `Sentry (~> 7.11.0)`.
Run Code Online (Sandbox Code Playgroud)
我只是想在我的 futter 项目中安装sentry_flutter 插件。目前我正在ios设备上进行测试。但它给出了上述错误。
错误消息看起来很简单。但我无法设法将此插件包含在我的项目中。