Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f742746

Browse files
authored
ref(node-core): Add mechanism to cron instrumentations (#17544)
- **ref(node-core): Add `mechanism` to cron instrumentations** - **adjust tests** ref #17260
1 parent 15e22cd commit f742746

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

‎dev-packages/node-core-integration-tests/suites/cron/cron/test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ test('cron instrumentation', async () => {
6969
})
7070
.expect({
7171
event: {
72-
exception: { values: [{ type: 'Error', value: 'Error in cron job' }] },
72+
exception: {
73+
values: [
74+
{
75+
type: 'Error',
76+
value: 'Error in cron job',
77+
mechanism: { type: 'auto.function.cron.instrumentCron', handled: false },
78+
},
79+
],
80+
},
7381
},
7482
})
7583
.start()

‎dev-packages/node-core-integration-tests/suites/cron/node-cron/test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ test('node-cron instrumentation', async () => {
6969
})
7070
.expect({
7171
event: {
72-
exception: { values: [{ type: 'Error', value: 'Error in cron job' }] },
72+
exception: {
73+
values: [
74+
{
75+
type: 'Error',
76+
value: 'Error in cron job',
77+
mechanism: { type: 'auto.function.node-cron.instrumentNodeCron', handled: false },
78+
},
79+
],
80+
},
7381
},
7482
})
7583
.start()

‎dev-packages/node-core-integration-tests/suites/cron/node-schedule/test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,15 @@ test('node-schedule instrumentation', async () => {
6969
})
7070
.expect({
7171
event: {
72-
exception: { values: [{ type: 'Error', value: 'Error in cron job' }] },
72+
exception: {
73+
values: [
74+
{
75+
type: 'Error',
76+
value: 'Error in cron job',
77+
mechanism: { type: 'onunhandledrejection', handled: false },
78+
},
79+
],
80+
},
7381
},
7482
})
7583
.start()

‎packages/node-core/src/cron/cron.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ export function instrumentCron<T>(lib: T & CronJobConstructor, monitorSlug: stri
9999
try {
100100
await onTick(context, onComplete);
101101
} catch (e) {
102-
captureException(e);
102+
captureException(e, {
103+
mechanism: {
104+
handled: false,
105+
type: 'auto.function.cron.instrumentCron',
106+
},
107+
});
103108
throw e;
104109
}
105110
},
@@ -136,7 +141,12 @@ export function instrumentCron<T>(lib: T & CronJobConstructor, monitorSlug: stri
136141
try {
137142
await onTick(context, onComplete);
138143
} catch (e) {
139-
captureException(e);
144+
captureException(e, {
145+
mechanism: {
146+
handled: false,
147+
type: 'auto.function.cron.instrumentCron',
148+
},
149+
});
140150
throw e;
141151
}
142152
},

‎packages/node-core/src/cron/node-cron.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ export function instrumentNodeCron<T>(lib: Partial<NodeCron> & T): T {
5353
try {
5454
return await callback();
5555
} catch (e) {
56-
captureException(e);
56+
captureException(e, {
57+
mechanism: {
58+
handled: false,
59+
type: 'auto.function.node-cron.instrumentNodeCron',
60+
},
61+
});
5762
throw e;
5863
}
5964
},

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /