node.js - aws Lambda 上的哨兵面包屑
问题描述
当 AWS Lambda 函数被冻结并重新启动(热启动)时,之前的面包屑消息仍然存在,并且在 Sentry 仪表板上我们可以看到旧消息。
似乎在 captureException 调用后没有清除面包屑。即使函数被重用,哪种方法是清除调用之间上下文的正确方法?
Sentry.init({
dsn: process.env.dsn,
environment: process.env.environment,
release: process.env.release
});
try {
Sentry.configureScope(scope => {
scope.setTag('transaction', context.awsRequestId);
scope.setTag('lambda', context.functionName);
});
Sentry.addBreadcrumb({
category: 'store',
message: 'Test',
level: Sentry.Severity.Info
});
throw new Error('Something bad happened');
} catch (error) {
context.callbackWaitsForEmptyEventLoop = false;
Sentry.captureException(error);
await Sentry.flush(context.getRemainingTimeInMillis());
}
解决方案
对于这方面的稀疏文档感到抱歉,但在此之后立即执行init
:
Sentry.configureScope(scope => {
scope.clear();
});
应该做的伎俩。
推荐阅读
- postgresql - Postgressql 工具/导入灰显
- java - 改造到 GraphQL
- javascript - Angular 12 日期选择器
- android - logback不写文件android 11
- flutter - 如何在 Flutter 中将 GIF 转换为 mp4 视频?
- rest - 使用 Azure DevOps REST Api 如何获取默认分支?
- ajax - 渲染人物运动
- linear-programming - 检查列生成中新列的成本降低
- r - 从 R 中的向量返回条件选择对的最大值
- rest - 当 URI 上没有用户 ID 时如何设计 RESTful API URI