如何在Sentry中使用captureMessage时更改事件的标题(Node.js)

kr98yfug  于 2023-05-22  发布在  Node.js
关注(0)|答案(1)|浏览(167)

我在我的Node.js项目中使用Sentry进行错误日志记录,它工作得很好。我还开始使用Sentry来捕获某些事件,这些事件在Sentry中显示为蓝色标记,而不是橙子(我相信橙色代表错误)。
我似乎无法控制的是事件的标题,它总是显示为Error。我想将其更改为更能代表正在发生的事情的东西,例如MessageLog,因为这些事件不是错误。
这可能吗?我已经通过哨兵文档,但似乎无法找到如何可以改变。
同样奇怪的是,如果我在Node.js中将级别设置为log,它似乎不会在Sentry中反映出来。它总是显示为info

fastify.sentry.withScope(function(scope) {
    scope.setLevel('log')
    scope.setTransactionName('Create Transaction')
    scope.setExtra('Transaction UUID', uuid)
    scope.setExtra('Merchant ID', merchantId)
    scope.setExtra('Body', body)
    scope.setExtra('Transaction ID', transactionId)
    fastify.sentry.captureMessage(uuid)
})

h7appiyu

h7appiyu1#

解决这个问题纯属侥幸。
如果我执行以下操作,Sentry将更改标题:

fastify.sentry.withScope(function(scope) {
    scope.setLevel('log')
    scope.setTransactionName('Create Transaction')
    scope.setExtra('Transaction UUID', uuid)
    scope.setExtra('Merchant ID', merchantId)
    scope.setExtra('Body', body)
    scope.setExtra('Transaction ID', transactionId)
    fastify.sentry.captureMessage(`Log: ${uuid}`)
})

相关问题