getsentry / getsentry/sentry-javascript

Add crons integration extending OpenTelementry and remove Sentry cron wrapper

Đang mở
#11,790 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
Checks Crons Improvement Node.js
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ả

### Problem Statement

The current setup for monitoring crons requires a wrapper function ([link to docs](https://docs.sentry.io/platforms/javascript/guides/node/crons/)). You use it like this:

```js
const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'cron_slug');

const job = CronJobWithCheckIn.from({
cronTime: '7 * * * * *',
onTick: () => {
console.log('cron: Job is running every few seconds');
},
});

job.start();
```

### Solution Brainstorm

We could add a new integration which is extending OpenTelementry and publish it as separate packages and remove the wrapper, which is currently needed. These OTEL instrumentations can also automatically create spans, something that is not supported atm.

If we make these integrations, we need them to be opt-in because crons charge per monitor. We have two options:

1. Have users explicitly add integrations, with ability to specify monitors they are only interested in
2. Have all cron integrations enabled by default, but expose a public API options surface to manage what monitors are created.

```[tasklist]
### Phase 1: Initial Implementation
- [ ] Add `@sentry/opentelemetry-instrumentation-cron`
- [ ] Add `@sentry/opentelemetry-instrumentation-node-cron`
- [ ] Add `@sentry/opentelemetry-instrumentation-node-schedule`
- [ ] Add integration for `cron`
- [ ] Add integration for `node-cron`
- [ ] Add integration for `node-schedule`
```

```[tasklist]
### Phase 1: Migration
- [ ] Update docs
- [ ] Deprecate `Sentry.cron` methods
```

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.