Skip to content

Commit 5ee4391

Browse files
committed
feat(deno): Add denoDataloaderIntegration
1 parent 42e8f8e commit 5ee4391

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

packages/deno/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ export type { DenoRedisIntegrationOptions } from './integrations/redis';
114114
export { denoMysqlIntegration } from './integrations/mysql';
115115
export { denoPostgresIntegration } from './integrations/postgres';
116116
export { denoAmqplibIntegration } from './integrations/amqplib';
117+
export { denoDataloaderIntegration } from './integrations/dataloader';
117118
export { denoContextIntegration } from './integrations/context';
118119
export { globalHandlersIntegration } from './integrations/globalhandlers';
119120
export { normalizePathsIntegration } from './integrations/normalizepaths';
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { dataloaderChannelIntegration } from '@sentry/server-utils/orchestrion';
2+
import type { Integration, IntegrationFn } from '@sentry/core';
3+
import { defineIntegration, extendIntegration } from '@sentry/core';
4+
import { setAsyncLocalStorageAsyncContextStrategy } from '../async';
5+
6+
const INTEGRATION_NAME = 'DenoDataloader' as const;
7+
8+
/**
9+
* Create spans for `dataloader` load/batch operations under Deno.
10+
*
11+
* `dataloader` channels are injected by the orchestrion runtime hook at load time.
12+
* The `@sentry/deno/import` loader must be active for this integration to
13+
* record anything.
14+
*
15+
* The channel-subscription logic is shared with the other server runtimes in
16+
* `@sentry/server-utils`. This just installs Deno's `AsyncLocalStorage` context
17+
* strategy (so spans nest under the active span and survive dataloader's deferred
18+
* batch dispatch) before delegating.
19+
*/
20+
const _denoDataloaderIntegration = (() => {
21+
const inner = dataloaderChannelIntegration();
22+
23+
return extendIntegration(inner, {
24+
name: INTEGRATION_NAME,
25+
setupOnce() {
26+
setAsyncLocalStorageAsyncContextStrategy();
27+
},
28+
});
29+
}) satisfies IntegrationFn;
30+
31+
export const denoDataloaderIntegration = defineIntegration(_denoDataloaderIntegration) as () => Integration & {
32+
name: 'DenoDataloader';
33+
setupOnce: () => void;
34+
};

0 commit comments

Comments
 (0)