英文:
why sentry config in nest express app dose not show spans in doshboard?
问题
添加Sentry到Nest应用后,'http.server' span 就会添加到仪表板中。
我的配置如下:
Sentry.init({
dsn: configService.get('SENTRY_DSN'),
tracesSampleRate: +configService.get('SENTRY_SAMPLE_RATE'),
sampleRate: +configService.get('SENTRY_SAMPLE_RATE'),
environment: configService.get('NODE_ENV'),
debug: true,
attachStacktrace: true,
integrations: [
new Sentry.Integrations.Http(),
new Sentry.Integrations.Mysql(),
new Sentry.Integrations.Modules(),
new Sentry.Integrations.Express(),
],
});
app.use(
Sentry.Handlers.requestHandler({
ip: true,
request: true,
transaction: true,
user: true,
}),
);
app.use(Sentry.Handlers.tracingHandler());
// ...
app.use(Sentry.Handlers.errorHandler());
我的包版本如下:
"@sentry/node": "^7.58.0",
"@sentry-internal/tracing": "7.58.0",
"@sentry/core": "7.58.0",
"@sentry/types": "7.58.0",
"@sentry/utils": "7.58.0",
我需要在仪表板中获取其他 spans。
英文:
After I add Senty to nest app, 'http.server' span just added to the dashboard.
My config is:
Sentry.init({
dsn: configService.get('SENTRY_DSN'),
tracesSampleRate: +configService.get('SENTRY_SAMPLE_RATE'),
sampleRate: +configService.get('SENTRY_SAMPLE_RATE'),
environment: configService.get('NODE_ENV'),
debug: true,
attachStacktrace: true,
integrations: [
new Sentry.Integrations.Http(),
new Sentry.Integrations.Mysql(),
new Sentry.Integrations.Modules(),
new Sentry.Integrations.Express(),
],
});
app.use(
Sentry.Handlers.requestHandler({
ip: true,
request: true,
transaction: true,
user: true,
}),
);
app.use(Sentry.Handlers.tracingHandler());
...
app.use(Sentry.Handlers.errorHandler());
and my packages are :
"@sentry/node": "^7.58.0",
"@sentry-internal/tracing": "7.58.0",
"@sentry/core": "7.58.0",
"@sentry/types": "7.58.0",
"@sentry/utils": "7.58.0",
I need to get other spans in doshboard
答案1
得分: 1
要添加自定义跨度,您可以使用 Sentry.startTransaction()
方法创建一个新事务,然后使用 Sentry.captureSpan()
方法在该事务内捕获单独的跨度。
const transaction = Sentry.startTransaction();
const span = transaction.startChild({
op: 'custom_operation',
description: '自定义操作的描述',
});
// 在这里执行您的自定义操作
span.finish();
transaction.finish();
英文:
To add custom spans, you can use the Sentry.startTransaction()
method to create a new transaction and then use the Sentry.captureSpan()
method to capture individual spans within that transaction.
const transaction = Sentry.startTransaction();
const span = transaction.startChild({
op: 'custom_operation',
description: 'Description of the custom operation',
});
// Perform your custom operation here
span.finish();
transaction.finish();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论