我正在尝试将@sentry/tracing集成到NodeJS + Express应用程序中。
似乎不是我能找到的任何文档(我已经向documentation 这里提交了一个问题)。
我已经查看了@sentry/跟踪代码,似乎有一个Express集成可用。
基于集成源代码,它看起来应该实例化如下所示:
const express = require('express');
const app = express();
const Sentry = require('@sentry/node');
const { Integrations } = require( "@sentry/tracing");
Sentry.init({
dsn: __MY_SENTRY_DSN__,
integrations: [
new Integrations.Express({app}),
]
});我试过了,但在Sentry中没有任何跟踪数据。
发布于 2020-08-27 10:53:50
好的,基本上,这里我们需要的主要跟踪组件是一个单独的express处理程序。
该跟踪处理程序实际上是@sentry/node包的一部分(因为逻辑),并且可以作为Sentry.Handlers.tracingHandler访问。
因此,正确的初始化步骤是:
Sentry.init({
tracesSampleRate: 1.0, // <- ** you need this one here (Note: the docs for the BrowserTracing version says to use less for production environment or it might suck all your quota) **
dsn: __MY_SENTRY_DSN__,
// ...
});
app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.tracingHandler()); // <- ** and add this one here **
// your route handlers
app.use(Sentry.Handlers.errorHandler());一旦配置好,您就应该开始在Performance .中看到跟踪数据。
这只剩下一个未回答的问题..。Integrations.Express__是什么?
基本上,它看起来正在做的事情(并且它是可选的)是显示跟踪中每个中间件调用的子框架(在它们的术语中是跨的)。
这里有一条没有:

这里有一个线索:

这就是我想出来的。如果你认为有任何错误或有更好的方法,请纠正我。
https://stackoverflow.com/questions/63613384
复制相似问题