getsentry / getsentry/sentry-javascript

Trace isolation not working in with express/apollo app causing unrelated logs to have the same trace id

Đang mở
#17,704 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Bug State: Needs Discussion
Ngôn ngữ chính
TypeScript
Star
8.7k
Fork
1.8k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
515

Mô tả

Sentry feedback: https://sentry.sentry.io/issues/feedback/?feedbackSlug=javascript%3A6854743819&project=11276

### Description

> Our app is very simple, just a docker container running node , Apollo server v4 w/ Express , deployed on Google Cloud Run.

```js
import { sentry as sentryConfig, service } from '@config'

import 'isomorphic-fetch'
import * as Sentry from '@sentry/node'
import { getRequestInfo } from '@shared/requestAsyncLocalStorage'

Sentry.init({
environment: sentryConfig.environment,
dsn: sentryConfig.dsn,
normalizeDepth: 7,
release: sentryConfig.release,
initialScope: {
tags: {
service,
},
},
ignoreErrors: ['You must be signed in to do this', 'too often'],
beforeBreadcrumb: (breadcrumb) => {
// ignore Apollo server reporting
// otherwise, the global scope will be polluted with useless breadcrumbs
// and useful ones will be discarded when hitting maxBreadcrumbs limit
if (
breadcrumb.category === 'http' &&
breadcrumb.message &&
breadcrumb.message.includes('[usage-reporting.api.apollographql.com](http://usage-reporting.api.apollographql.com/)')
) {
return null
}

return breadcrumb
},
beforeSendLog: (log) => {
// Can't override sentry's traceId, so we need to add it to the attributes
const requestInfo = getRequestInfo()

if (requestInfo.traceId && log.attributes) {
log.attributes.traceId = requestInfo.traceId
}

return log
},
enableLogs: true,
integrations: (defaults) => [
...defaults,
Sentry.rewriteFramesIntegration({
root: __dirname || process.cwd(),
}),
Sentry.modulesIntegration(),
],
})
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.