|
1 | | -import { _INTERNAL_safeDateNow, defineIntegration, metrics } from '@sentry/core'; |
| 1 | +import { _INTERNAL_safeDateNow, _INTERNAL_safeUnref, defineIntegration, metrics } from '@sentry/core'; |
2 | 2 |
|
3 | 3 | const INTEGRATION_NAME = 'DenoRuntimeMetrics'; |
4 | 4 | const DEFAULT_INTERVAL_MS = 30_000; |
@@ -57,7 +57,7 @@ export const denoRuntimeMetricsIntegration = defineIntegration((options: DenoRun |
57 | 57 | ...options.collect, |
58 | 58 | }; |
59 | 59 |
|
60 | | - let intervalId: number | undefined; |
| 60 | + let intervalId: ReturnType<typeof setInterval> | undefined; |
61 | 61 | let prevFlushTime: number = 0; |
62 | 62 |
|
63 | 63 | const METRIC_ATTRIBUTES_BYTE = { unit: 'byte', attributes: { 'sentry.origin': 'auto.deno.runtime_metrics' } }; |
@@ -100,12 +100,7 @@ export const denoRuntimeMetricsIntegration = defineIntegration((options: DenoRun |
100 | 100 | if (intervalId) { |
101 | 101 | clearInterval(intervalId); |
102 | 102 | } |
103 | | - // In Deno, setInterval returns a number, so _INTERNAL_safeUnref is a no-op. |
104 | | - // Use Deno.unrefTimer so the interval doesn't prevent the process from exiting. |
105 | | - // Cast to number since the tsconfig.types.json build context resolves setInterval |
106 | | - // to Node's NodeJS.Timeout rather than the Deno/browser number type. |
107 | | - intervalId = setInterval(collectMetrics, collectionIntervalMs) as unknown as number; |
108 | | - Deno.unrefTimer(intervalId); |
| 103 | + intervalId = _INTERNAL_safeUnref(setInterval(collectMetrics, collectionIntervalMs)); |
109 | 104 | }, |
110 | 105 |
|
111 | 106 | teardown(): void { |
|
0 commit comments