getsentry / getsentry/sentry-javascript

Add diagnostics_channel based instrumentation to supported Node libraries

Đang mở
#15,107 4 bình luận 2 reaction 0 người được giao Xem trên GitHub
Tracking Issue
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ả

### Description

Today, we use `import-in-the-middle` and `require-in-the-middle` based instrumentation for Node libraries in our Node SDK, e.g. for express, mysql, etc.

This has some downsides:

1. For ESM, to have `import-in-the-middle` work reliably it should be configured via `--import` in the Node CLI
2. `import-in-the-middle` is flawed in a couple of ways that means it can't be used to wrap all libraries
3. Neither `import-in-the-middle` or `require-in-the-middle` work with bundled code (as it instruments `import`/`require`, basically)

To "fix" this, we want to migrate to using [`diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html) for the packages we instrument. With this, both of these downsides disappear.

In order to achieve this, we need to actually PR the libraries themselves (e.g. express, mysql, ...) and make them emit `diagnostics_channel` (or a [tracing channel](https://nodejs.org/api/diagnostics_channel.html#class-tracingchannel)). Then, the OTEL instrumentation can be updated to use this instead of using import-in-the-middle.

This will be a gradual approach, we can update libraries as we go, starting with more important ones.

```[tasklist]
### Libraries to update
- [ ] http
- [ ] express
- [ ] fastify
- [ ] graphql
- [ ] mongo
- [ ] mongoose
- [ ] mysql
- [ ] mysql2
- [ ] redis
- [ ] postgres
- [ ] hapi
- [ ] koa
- [ ] connect
- [ ] tedious
- [ ] genericPool
- [ ] kafka
- [ ] amqlib
- [ ] lruMemoizer
- [ ] vercelAIIntergation (?)
```

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.