@sentry/cloudflare 10.53.0 → 10.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/async.js +4 -30
- package/build/cjs/async.js.map +1 -1
- package/build/cjs/client.js +31 -58
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/d1.js +26 -80
- package/build/cjs/d1.js.map +1 -1
- package/build/cjs/debug-build.js +0 -5
- package/build/cjs/debug-build.js.map +1 -1
- package/build/cjs/durableobject.js +44 -131
- package/build/cjs/durableobject.js.map +1 -1
- package/build/cjs/flush.js +47 -34
- package/build/cjs/flush.js.map +1 -1
- package/build/cjs/instrument.js +7 -48
- package/build/cjs/instrument.js.map +1 -1
- package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js +9 -34
- package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +20 -54
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +12 -66
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentEmail.js +21 -43
- package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentEnv.js +12 -42
- package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentFetch.js +20 -34
- package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentFetcher.js +5 -19
- package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentQueue.js +30 -62
- package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentQueueProducer.js +31 -57
- package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentScheduled.js +25 -54
- package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentTail.js +16 -43
- package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/cjs/integrations/fetch.js +24 -56
- package/build/cjs/integrations/fetch.js.map +1 -1
- package/build/cjs/integrations/hono.js +7 -38
- package/build/cjs/integrations/hono.js.map +1 -1
- package/build/cjs/integrations/httpServer.js +6 -39
- package/build/cjs/integrations/httpServer.js.map +1 -1
- package/build/cjs/integrations/tracing/vercelai.js +3 -31
- package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
- package/build/cjs/opentelemetry/tracer.js +17 -45
- package/build/cjs/opentelemetry/tracer.js.map +1 -1
- package/build/cjs/options.js +10 -46
- package/build/cjs/options.js.map +1 -1
- package/build/cjs/pages-plugin.js +9 -42
- package/build/cjs/pages-plugin.js.map +1 -1
- package/build/cjs/request.js +21 -67
- package/build/cjs/request.js.map +1 -1
- package/build/cjs/scope-utils.js +4 -15
- package/build/cjs/scope-utils.js.map +1 -1
- package/build/cjs/sdk.js +8 -25
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/transport.js +14 -48
- package/build/cjs/transport.js.map +1 -1
- package/build/cjs/utils/instrumentContext.js +16 -52
- package/build/cjs/utils/instrumentContext.js.map +1 -1
- package/build/cjs/utils/isBinding.js +3 -23
- package/build/cjs/utils/isBinding.js.map +1 -1
- package/build/cjs/utils/isCloudflareClass.js +2 -8
- package/build/cjs/utils/isCloudflareClass.js.map +1 -1
- package/build/cjs/utils/rpcMeta.js +8 -32
- package/build/cjs/utils/rpcMeta.js.map +1 -1
- package/build/cjs/utils/rpcOptions.js +9 -32
- package/build/cjs/utils/rpcOptions.js.map +1 -1
- package/build/cjs/utils/streaming.js +3 -29
- package/build/cjs/utils/streaming.js.map +1 -1
- package/build/cjs/utils/traceLinks.js +8 -33
- package/build/cjs/utils/traceLinks.js.map +1 -1
- package/build/cjs/vendor/stacktrace.js +6 -27
- package/build/cjs/vendor/stacktrace.js.map +1 -1
- package/build/cjs/withSentry.js +16 -47
- package/build/cjs/withSentry.js.map +1 -1
- package/build/cjs/workflows.js +40 -100
- package/build/cjs/workflows.js.map +1 -1
- package/build/cjs/wrapMethodWithSentry.js +110 -167
- package/build/cjs/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/async.js +4 -30
- package/build/esm/async.js.map +1 -1
- package/build/esm/client.js +31 -58
- package/build/esm/client.js.map +1 -1
- package/build/esm/d1.js +26 -80
- package/build/esm/d1.js.map +1 -1
- package/build/esm/debug-build.js +0 -5
- package/build/esm/debug-build.js.map +1 -1
- package/build/esm/durableobject.js +44 -131
- package/build/esm/durableobject.js.map +1 -1
- package/build/esm/flush.js +47 -34
- package/build/esm/flush.js.map +1 -1
- package/build/esm/instrument.js +7 -48
- package/build/esm/instrument.js.map +1 -1
- package/build/esm/instrumentations/instrumentDurableObjectNamespace.js +9 -34
- package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js +20 -54
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +12 -66
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentEmail.js +21 -43
- package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentEnv.js +12 -42
- package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentFetch.js +20 -34
- package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentFetcher.js +5 -19
- package/build/esm/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentQueue.js +30 -62
- package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentQueueProducer.js +31 -57
- package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentScheduled.js +25 -54
- package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentTail.js +16 -43
- package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/esm/integrations/fetch.js +24 -56
- package/build/esm/integrations/fetch.js.map +1 -1
- package/build/esm/integrations/hono.js +7 -38
- package/build/esm/integrations/hono.js.map +1 -1
- package/build/esm/integrations/httpServer.js +6 -39
- package/build/esm/integrations/httpServer.js.map +1 -1
- package/build/esm/integrations/tracing/vercelai.js +3 -31
- package/build/esm/integrations/tracing/vercelai.js.map +1 -1
- package/build/esm/opentelemetry/tracer.js +17 -45
- package/build/esm/opentelemetry/tracer.js.map +1 -1
- package/build/esm/options.js +10 -46
- package/build/esm/options.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/pages-plugin.js +9 -42
- package/build/esm/pages-plugin.js.map +1 -1
- package/build/esm/request.js +21 -67
- package/build/esm/request.js.map +1 -1
- package/build/esm/scope-utils.js +4 -15
- package/build/esm/scope-utils.js.map +1 -1
- package/build/esm/sdk.js +8 -25
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/transport.js +14 -48
- package/build/esm/transport.js.map +1 -1
- package/build/esm/utils/instrumentContext.js +16 -52
- package/build/esm/utils/instrumentContext.js.map +1 -1
- package/build/esm/utils/isBinding.js +3 -23
- package/build/esm/utils/isBinding.js.map +1 -1
- package/build/esm/utils/isCloudflareClass.js +2 -8
- package/build/esm/utils/isCloudflareClass.js.map +1 -1
- package/build/esm/utils/rpcMeta.js +8 -32
- package/build/esm/utils/rpcMeta.js.map +1 -1
- package/build/esm/utils/rpcOptions.js +9 -32
- package/build/esm/utils/rpcOptions.js.map +1 -1
- package/build/esm/utils/streaming.js +3 -29
- package/build/esm/utils/streaming.js.map +1 -1
- package/build/esm/utils/traceLinks.js +8 -33
- package/build/esm/utils/traceLinks.js.map +1 -1
- package/build/esm/vendor/stacktrace.js +6 -27
- package/build/esm/vendor/stacktrace.js.map +1 -1
- package/build/esm/withSentry.js +16 -47
- package/build/esm/withSentry.js.map +1 -1
- package/build/esm/workflows.js +40 -100
- package/build/esm/workflows.js.map +1 -1
- package/build/esm/wrapMethodWithSentry.js +110 -167
- package/build/esm/wrapMethodWithSentry.js.map +1 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/flush.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
- package/build/types/pages-plugin.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -7,94 +7,65 @@ import { init } from '../../sdk.js';
|
|
|
7
7
|
import { instrumentContext } from '../../utils/instrumentContext.js';
|
|
8
8
|
import { instrumentEnv } from './instrumentEnv.js';
|
|
9
9
|
|
|
10
|
-
function wrapScheduledHandler(
|
|
11
|
-
|
|
12
|
-
options,
|
|
13
|
-
context,
|
|
14
|
-
fn,
|
|
15
|
-
) {
|
|
16
|
-
return withIsolationScope(isolationScope => {
|
|
10
|
+
function wrapScheduledHandler(controller, options, context, fn) {
|
|
11
|
+
return withIsolationScope((isolationScope) => {
|
|
17
12
|
const waitUntil = context.waitUntil.bind(context);
|
|
18
|
-
|
|
19
13
|
const client = init({ ...options, ctx: context });
|
|
20
14
|
isolationScope.setClient(client);
|
|
21
|
-
|
|
22
15
|
addCloudResourceContext(isolationScope);
|
|
23
|
-
|
|
24
16
|
return startSpan(
|
|
25
17
|
{
|
|
26
|
-
op:
|
|
18
|
+
op: "faas.cron",
|
|
27
19
|
name: `Scheduled Cron ${controller.cron}`,
|
|
28
20
|
attributes: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]:
|
|
33
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]:
|
|
34
|
-
}
|
|
21
|
+
"faas.cron": controller.cron,
|
|
22
|
+
"faas.time": new Date(controller.scheduledTime).toISOString(),
|
|
23
|
+
"faas.trigger": "timer",
|
|
24
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: "auto.faas.cloudflare.scheduled",
|
|
25
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: "task"
|
|
26
|
+
}
|
|
35
27
|
},
|
|
36
28
|
async () => {
|
|
37
29
|
try {
|
|
38
30
|
return await fn();
|
|
39
31
|
} catch (e) {
|
|
40
|
-
captureException(e, { mechanism: { handled: false, type:
|
|
32
|
+
captureException(e, { mechanism: { handled: false, type: "auto.faas.cloudflare.scheduled" } });
|
|
41
33
|
throw e;
|
|
42
34
|
} finally {
|
|
43
35
|
waitUntil(flushAndDispose(client));
|
|
44
36
|
}
|
|
45
|
-
}
|
|
37
|
+
}
|
|
46
38
|
);
|
|
47
39
|
});
|
|
48
40
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
* Instruments a scheduled handler for ExportedHandler (env/ctx come from args).
|
|
52
|
-
*/
|
|
53
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
54
|
-
function instrumentExportedHandlerScheduled(
|
|
55
|
-
handler,
|
|
56
|
-
optionsCallback,
|
|
57
|
-
) {
|
|
58
|
-
if (!('scheduled' in handler) || typeof handler.scheduled !== 'function') {
|
|
41
|
+
function instrumentExportedHandlerScheduled(handler, optionsCallback) {
|
|
42
|
+
if (!("scheduled" in handler) || typeof handler.scheduled !== "function") {
|
|
59
43
|
return;
|
|
60
44
|
}
|
|
61
|
-
|
|
62
45
|
handler.scheduled = ensureInstrumented(
|
|
63
46
|
handler.scheduled,
|
|
64
|
-
original =>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
}),
|
|
47
|
+
(original) => new Proxy(original, {
|
|
48
|
+
apply(target, thisArg, args) {
|
|
49
|
+
const [controller, env, ctx] = args;
|
|
50
|
+
const context = instrumentContext(ctx);
|
|
51
|
+
const options = getFinalOptions(optionsCallback(env), env);
|
|
52
|
+
args[1] = instrumentEnv(env, options);
|
|
53
|
+
args[2] = context;
|
|
54
|
+
return wrapScheduledHandler(controller, options, context, () => target.apply(thisArg, args));
|
|
55
|
+
}
|
|
56
|
+
})
|
|
76
57
|
);
|
|
77
58
|
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Instruments a scheduled method for WorkerEntrypoint (options/context already available).
|
|
81
|
-
*/
|
|
82
|
-
function instrumentWorkerEntrypointScheduled(
|
|
83
|
-
instance,
|
|
84
|
-
options,
|
|
85
|
-
context,
|
|
86
|
-
) {
|
|
59
|
+
function instrumentWorkerEntrypointScheduled(instance, options, context) {
|
|
87
60
|
if (!instance.scheduled) {
|
|
88
61
|
return;
|
|
89
62
|
}
|
|
90
|
-
|
|
91
63
|
const original = instance.scheduled.bind(instance);
|
|
92
64
|
instance.scheduled = new Proxy(original, {
|
|
93
65
|
apply(target, thisArg, args) {
|
|
94
66
|
const [controller] = args;
|
|
95
|
-
|
|
96
67
|
return wrapScheduledHandler(controller, options, context, () => Reflect.apply(target, thisArg, args));
|
|
97
|
-
}
|
|
68
|
+
}
|
|
98
69
|
});
|
|
99
70
|
}
|
|
100
71
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentScheduled.js","sources":["../../../../src/instrumentations/worker/instrumentScheduled.ts"],"sourcesContent":["import type { ExportedHandler, ScheduledController } from '@cloudflare/workers-types';\nimport type { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';\nimport {\n captureException,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from '../../client';\nimport { flushAndDispose } from '../../flush';\nimport { ensureInstrumented } from '../../instrument';\nimport { getFinalOptions } from '../../options';\nimport { addCloudResourceContext } from '../../scope-utils';\nimport { init } from '../../sdk';\nimport { instrumentContext } from '../../utils/instrumentContext';\nimport { instrumentEnv } from './instrumentEnv';\n\nfunction wrapScheduledHandler(\n controller: ScheduledController,\n options: CloudflareOptions,\n context: ExecutionContext,\n fn: () => unknown,\n): unknown {\n return withIsolationScope(isolationScope => {\n const waitUntil = context.waitUntil.bind(context);\n\n const client = init({ ...options, ctx: context });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return startSpan(\n {\n op: 'faas.cron',\n name: `Scheduled Cron ${controller.cron}`,\n attributes: {\n 'faas.cron': controller.cron,\n 'faas.time': new Date(controller.scheduledTime).toISOString(),\n 'faas.trigger': 'timer',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.scheduled',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await fn();\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.scheduled' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n },\n );\n });\n}\n\n/**\n * Instruments a scheduled handler for ExportedHandler (env/ctx come from args).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentExportedHandlerScheduled<T extends ExportedHandler<any, any, any>>(\n handler: T,\n optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined,\n): void {\n if (!('scheduled' in handler) || typeof handler.scheduled !== 'function') {\n return;\n }\n\n handler.scheduled = ensureInstrumented(\n handler.scheduled,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args: Parameters<NonNullable<T['scheduled']>>) {\n const [controller, env, ctx] = args;\n const context = instrumentContext(ctx);\n const options = getFinalOptions(optionsCallback(env), env);\n args[1] = instrumentEnv(env, options);\n args[2] = context;\n\n return wrapScheduledHandler(controller, options, context, () => target.apply(thisArg, args));\n },\n }),\n );\n}\n\n/**\n * Instruments a scheduled method for WorkerEntrypoint (options/context already available).\n */\nexport function instrumentWorkerEntrypointScheduled<T extends WorkerEntrypoint>(\n instance: T,\n options: CloudflareOptions,\n context: ExecutionContext,\n): void {\n if (!instance.scheduled) {\n return;\n }\n\n const original = instance.scheduled.bind(instance);\n instance.scheduled = new Proxy(original, {\n apply(target, thisArg, args: [ScheduledController]) {\n const [controller] = args;\n\n return wrapScheduledHandler(controller, options, context, () => Reflect.apply(target, thisArg, args));\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAkBA,SAAS,
|
|
1
|
+
{"version":3,"file":"instrumentScheduled.js","sources":["../../../../src/instrumentations/worker/instrumentScheduled.ts"],"sourcesContent":["import type { ExportedHandler, ScheduledController } from '@cloudflare/workers-types';\nimport type { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';\nimport {\n captureException,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from '../../client';\nimport { flushAndDispose } from '../../flush';\nimport { ensureInstrumented } from '../../instrument';\nimport { getFinalOptions } from '../../options';\nimport { addCloudResourceContext } from '../../scope-utils';\nimport { init } from '../../sdk';\nimport { instrumentContext } from '../../utils/instrumentContext';\nimport { instrumentEnv } from './instrumentEnv';\n\nfunction wrapScheduledHandler(\n controller: ScheduledController,\n options: CloudflareOptions,\n context: ExecutionContext,\n fn: () => unknown,\n): unknown {\n return withIsolationScope(isolationScope => {\n const waitUntil = context.waitUntil.bind(context);\n\n const client = init({ ...options, ctx: context });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n return startSpan(\n {\n op: 'faas.cron',\n name: `Scheduled Cron ${controller.cron}`,\n attributes: {\n 'faas.cron': controller.cron,\n 'faas.time': new Date(controller.scheduledTime).toISOString(),\n 'faas.trigger': 'timer',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.scheduled',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await fn();\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.scheduled' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n },\n );\n });\n}\n\n/**\n * Instruments a scheduled handler for ExportedHandler (env/ctx come from args).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentExportedHandlerScheduled<T extends ExportedHandler<any, any, any>>(\n handler: T,\n optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined,\n): void {\n if (!('scheduled' in handler) || typeof handler.scheduled !== 'function') {\n return;\n }\n\n handler.scheduled = ensureInstrumented(\n handler.scheduled,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args: Parameters<NonNullable<T['scheduled']>>) {\n const [controller, env, ctx] = args;\n const context = instrumentContext(ctx);\n const options = getFinalOptions(optionsCallback(env), env);\n args[1] = instrumentEnv(env, options);\n args[2] = context;\n\n return wrapScheduledHandler(controller, options, context, () => target.apply(thisArg, args));\n },\n }),\n );\n}\n\n/**\n * Instruments a scheduled method for WorkerEntrypoint (options/context already available).\n */\nexport function instrumentWorkerEntrypointScheduled<T extends WorkerEntrypoint>(\n instance: T,\n options: CloudflareOptions,\n context: ExecutionContext,\n): void {\n if (!instance.scheduled) {\n return;\n }\n\n const original = instance.scheduled.bind(instance);\n instance.scheduled = new Proxy(original, {\n apply(target, thisArg, args: [ScheduledController]) {\n const [controller] = args;\n\n return wrapScheduledHandler(controller, options, context, () => Reflect.apply(target, thisArg, args));\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAkBA,SAAS,oBAAA,CACP,UAAA,EACA,OAAA,EACA,OAAA,EACA,EAAA,EACS;AACT,EAAA,OAAO,mBAAmB,CAAA,cAAA,KAAkB;AAC1C,IAAA,MAAM,SAAA,GA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instrumentContext.js';
|
|
8
8
|
import { instrumentEnv } from './instrumentEnv.js';
|
|
9
9
|
|
|
10
|
-
/**
|
|
11
|
-
* Core tail handler logic - wraps execution with Sentry instrumentation.
|
|
12
|
-
* Note: tail handlers don't create spans, just error capture.
|
|
13
|
-
*/
|
|
14
10
|
function wrapTailHandler(options, context, fn) {
|
|
15
|
-
return withIsolationScope(async isolationScope => {
|
|
11
|
+
return withIsolationScope(async (isolationScope) => {
|
|
16
12
|
const waitUntil = context.waitUntil.bind(context);
|
|
17
|
-
|
|
18
13
|
const client = init({ ...options, ctx: context });
|
|
19
14
|
isolationScope.setClient(client);
|
|
20
|
-
|
|
21
15
|
addCloudResourceContext(isolationScope);
|
|
22
|
-
|
|
23
16
|
try {
|
|
24
17
|
return await fn();
|
|
25
18
|
} catch (e) {
|
|
26
|
-
captureException(e, { mechanism: { handled: false, type:
|
|
19
|
+
captureException(e, { mechanism: { handled: false, type: "auto.faas.cloudflare.tail" } });
|
|
27
20
|
throw e;
|
|
28
21
|
} finally {
|
|
29
22
|
waitUntil(flushAndDispose(client));
|
|
30
23
|
}
|
|
31
24
|
});
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
* Instruments a tail handler for ExportedHandler (env/ctx come from args).
|
|
36
|
-
*/
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
function instrumentExportedHandlerTail(
|
|
39
|
-
handler,
|
|
40
|
-
optionsCallback,
|
|
41
|
-
) {
|
|
42
|
-
if (!('tail' in handler) || typeof handler.tail !== 'function') {
|
|
26
|
+
function instrumentExportedHandlerTail(handler, optionsCallback) {
|
|
27
|
+
if (!("tail" in handler) || typeof handler.tail !== "function") {
|
|
43
28
|
return;
|
|
44
29
|
}
|
|
45
|
-
|
|
46
30
|
handler.tail = ensureInstrumented(
|
|
47
31
|
handler.tail,
|
|
48
|
-
original =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
}),
|
|
32
|
+
(original) => new Proxy(original, {
|
|
33
|
+
apply(target, thisArg, args) {
|
|
34
|
+
const [, env, ctx] = args;
|
|
35
|
+
const context = instrumentContext(ctx);
|
|
36
|
+
const options = getFinalOptions(optionsCallback(env), env);
|
|
37
|
+
args[1] = instrumentEnv(env, options);
|
|
38
|
+
args[2] = context;
|
|
39
|
+
return wrapTailHandler(options, context, () => target.apply(thisArg, args));
|
|
40
|
+
}
|
|
41
|
+
})
|
|
60
42
|
);
|
|
61
43
|
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Instruments a tail method for WorkerEntrypoint (options/context already available).
|
|
65
|
-
*/
|
|
66
|
-
function instrumentWorkerEntrypointTail(
|
|
67
|
-
instance,
|
|
68
|
-
options,
|
|
69
|
-
context,
|
|
70
|
-
) {
|
|
44
|
+
function instrumentWorkerEntrypointTail(instance, options, context) {
|
|
71
45
|
if (!instance.tail) {
|
|
72
46
|
return;
|
|
73
47
|
}
|
|
74
|
-
|
|
75
48
|
const original = instance.tail.bind(instance);
|
|
76
49
|
instance.tail = new Proxy(original, {
|
|
77
50
|
apply(target, thisArg, args) {
|
|
78
51
|
return wrapTailHandler(options, context, () => Reflect.apply(target, thisArg, args));
|
|
79
|
-
}
|
|
52
|
+
}
|
|
80
53
|
});
|
|
81
54
|
}
|
|
82
55
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentTail.js","sources":["../../../../src/instrumentations/worker/instrumentTail.ts"],"sourcesContent":["import type { ExportedHandler, TraceItem } from '@cloudflare/workers-types';\nimport type { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';\nimport { captureException, withIsolationScope } from '@sentry/core';\nimport type { CloudflareOptions } from '../../client';\nimport { flushAndDispose } from '../../flush';\nimport { ensureInstrumented } from '../../instrument';\nimport { getFinalOptions } from '../../options';\nimport { addCloudResourceContext } from '../../scope-utils';\nimport { init } from '../../sdk';\nimport { instrumentContext } from '../../utils/instrumentContext';\nimport { instrumentEnv } from './instrumentEnv';\n\n/**\n * Core tail handler logic - wraps execution with Sentry instrumentation.\n * Note: tail handlers don't create spans, just error capture.\n */\nfunction wrapTailHandler(options: CloudflareOptions, context: ExecutionContext, fn: () => unknown): unknown {\n return withIsolationScope(async isolationScope => {\n const waitUntil = context.waitUntil.bind(context);\n\n const client = init({ ...options, ctx: context });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n try {\n return await fn();\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.tail' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n });\n}\n\n/**\n * Instruments a tail handler for ExportedHandler (env/ctx come from args).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentExportedHandlerTail<T extends ExportedHandler<any, any, any>>(\n handler: T,\n optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined,\n): void {\n if (!('tail' in handler) || typeof handler.tail !== 'function') {\n return;\n }\n\n handler.tail = ensureInstrumented(\n handler.tail,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args: Parameters<NonNullable<T['tail']>>) {\n const [, env, ctx] = args;\n const context = instrumentContext(ctx);\n const options = getFinalOptions(optionsCallback(env), env);\n args[1] = instrumentEnv(env, options);\n args[2] = context;\n\n return wrapTailHandler(options, context, () => target.apply(thisArg, args));\n },\n }),\n );\n}\n\n/**\n * Instruments a tail method for WorkerEntrypoint (options/context already available).\n */\nexport function instrumentWorkerEntrypointTail<T extends WorkerEntrypoint>(\n instance: T,\n options: CloudflareOptions,\n context: ExecutionContext,\n): void {\n if (!instance.tail) {\n return;\n }\n\n const original = instance.tail.bind(instance);\n instance.tail = new Proxy(original, {\n apply(target, thisArg, args: [TraceItem[]]) {\n return wrapTailHandler(options, context, () => Reflect.apply(target, thisArg, args));\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"instrumentTail.js","sources":["../../../../src/instrumentations/worker/instrumentTail.ts"],"sourcesContent":["import type { ExportedHandler, TraceItem } from '@cloudflare/workers-types';\nimport type { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';\nimport { captureException, withIsolationScope } from '@sentry/core';\nimport type { CloudflareOptions } from '../../client';\nimport { flushAndDispose } from '../../flush';\nimport { ensureInstrumented } from '../../instrument';\nimport { getFinalOptions } from '../../options';\nimport { addCloudResourceContext } from '../../scope-utils';\nimport { init } from '../../sdk';\nimport { instrumentContext } from '../../utils/instrumentContext';\nimport { instrumentEnv } from './instrumentEnv';\n\n/**\n * Core tail handler logic - wraps execution with Sentry instrumentation.\n * Note: tail handlers don't create spans, just error capture.\n */\nfunction wrapTailHandler(options: CloudflareOptions, context: ExecutionContext, fn: () => unknown): unknown {\n return withIsolationScope(async isolationScope => {\n const waitUntil = context.waitUntil.bind(context);\n\n const client = init({ ...options, ctx: context });\n isolationScope.setClient(client);\n\n addCloudResourceContext(isolationScope);\n\n try {\n return await fn();\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.tail' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n });\n}\n\n/**\n * Instruments a tail handler for ExportedHandler (env/ctx come from args).\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function instrumentExportedHandlerTail<T extends ExportedHandler<any, any, any>>(\n handler: T,\n optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined,\n): void {\n if (!('tail' in handler) || typeof handler.tail !== 'function') {\n return;\n }\n\n handler.tail = ensureInstrumented(\n handler.tail,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args: Parameters<NonNullable<T['tail']>>) {\n const [, env, ctx] = args;\n const context = instrumentContext(ctx);\n const options = getFinalOptions(optionsCallback(env), env);\n args[1] = instrumentEnv(env, options);\n args[2] = context;\n\n return wrapTailHandler(options, context, () => target.apply(thisArg, args));\n },\n }),\n );\n}\n\n/**\n * Instruments a tail method for WorkerEntrypoint (options/context already available).\n */\nexport function instrumentWorkerEntrypointTail<T extends WorkerEntrypoint>(\n instance: T,\n options: CloudflareOptions,\n context: ExecutionContext,\n): void {\n if (!instance.tail) {\n return;\n }\n\n const original = instance.tail.bind(instance);\n instance.tail = new Proxy(original, {\n apply(target, thisArg, args: [TraceItem[]]) {\n return wrapTailHandler(options, context, () => Reflect.apply(target, thisArg, args));\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAgBA,SAAS,eAAA,CAAgB,OAAA,EAA4B,OAAA,EAA2B,EAAA,EAA4B;AAC1G,EAAA,OAAO,kBAAA,CAAmB,OAAM,cAAA,KAAkB;AAChD,IAAA,MAAM,SAAA,GAAY,OAAA,CAAQ,SAAA,CAAU,IAAA,CAAK,OAAO,CAAA;AAEhD,IAAA,MAAM,SAAS,IAAA,CAAK,EAAE,GAAG,OAAA,EAAS,GAAA,EAAK,SAAS,CAAA;AAChD,IAAA,cAAA,CAAe,UAAU,MAAM,CAAA;AAE/B,IAAA,uBAAA,CAAwB,cAAc,CAAA;AAEtC,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,EAAA,EAAG;AAAA,IAClB,SAAS,CAAA,EAAG;AACV,MAAA,gBAAA,CAAiB,CAAA,EAAG,EAAE,SAAA,EAAW,EAAE,SAAS,KAAA,EAAO,IAAA,EAAM,2BAAA,EAA4B,EAAG,CAAA;AACxF,MAAA,MAAM,CAAA;AAAA,IACR,CAAA,SAAE;AACA,MAAA,SAAA,CAAU,eAAA,CAAgB,MAAM,CAAC,CAAA;AAAA,IACnC;AAAA,EACF,CAAC,CAAA;AACH;AAMO,SAAS,6BAAA,CACd,SACA,eAAA,EACM;AACN,EAAA,IAAI,EAAE,MAAA,IAAU,OAAA,CAAA,IAAY,OAAO,OAAA,CAAQ,SAAS,UAAA,EAAY;AAC9D,IAAA;AAAA,EACF;AAEA,EAAA,OAAA,CA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ringMatchesSomePattern, addBreadcrumb, getBreadcrumbLogLevelFromHttpStatusCode } from '@sentry/core';
|
|
2
2
|
|
|
3
|
-
const INTEGRATION_NAME =
|
|
4
|
-
|
|
5
|
-
const HAS_CLIENT_MAP = new WeakMap();
|
|
6
|
-
|
|
3
|
+
const INTEGRATION_NAME = "Fetch";
|
|
4
|
+
const HAS_CLIENT_MAP = /* @__PURE__ */ new WeakMap();
|
|
7
5
|
const _fetchIntegration = ((options = {}) => {
|
|
8
|
-
const breadcrumbs = options.breadcrumbs ===
|
|
6
|
+
const breadcrumbs = options.breadcrumbs === void 0 ? true : options.breadcrumbs;
|
|
9
7
|
const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;
|
|
10
|
-
|
|
11
8
|
const _createSpanUrlMap = new LRUMap(100);
|
|
12
9
|
const _headersUrlMap = new LRUMap(100);
|
|
13
|
-
|
|
14
10
|
const spans = {};
|
|
15
|
-
|
|
16
|
-
/** Decides whether to attach trace data to the outgoing fetch request */
|
|
17
11
|
function _shouldAttachTraceData(url) {
|
|
18
12
|
const client = getClient();
|
|
19
|
-
|
|
20
13
|
if (!client) {
|
|
21
14
|
return false;
|
|
22
15
|
}
|
|
23
|
-
|
|
24
16
|
const clientOptions = client.getOptions();
|
|
25
|
-
|
|
26
|
-
if (clientOptions.tracePropagationTargets === undefined) {
|
|
17
|
+
if (clientOptions.tracePropagationTargets === void 0) {
|
|
27
18
|
return true;
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
const cachedDecision = _headersUrlMap.get(url);
|
|
31
|
-
if (cachedDecision !==
|
|
21
|
+
if (cachedDecision !== void 0) {
|
|
32
22
|
return cachedDecision;
|
|
33
23
|
}
|
|
34
|
-
|
|
35
24
|
const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);
|
|
36
25
|
_headersUrlMap.set(url, decision);
|
|
37
26
|
return decision;
|
|
38
27
|
}
|
|
39
|
-
|
|
40
|
-
/** Helper that wraps shouldCreateSpanForRequest option */
|
|
41
28
|
function _shouldCreateSpan(url) {
|
|
42
|
-
if (shouldCreateSpanForRequest ===
|
|
29
|
+
if (shouldCreateSpanForRequest === void 0) {
|
|
43
30
|
return true;
|
|
44
31
|
}
|
|
45
|
-
|
|
46
32
|
const cachedDecision = _createSpanUrlMap.get(url);
|
|
47
|
-
if (cachedDecision !==
|
|
33
|
+
if (cachedDecision !== void 0) {
|
|
48
34
|
return cachedDecision;
|
|
49
35
|
}
|
|
50
|
-
|
|
51
36
|
const decision = shouldCreateSpanForRequest(url);
|
|
52
37
|
_createSpanUrlMap.set(url, decision);
|
|
53
38
|
return decision;
|
|
54
39
|
}
|
|
55
|
-
|
|
56
40
|
return {
|
|
57
41
|
name: INTEGRATION_NAME,
|
|
58
42
|
setupOnce() {
|
|
59
|
-
addFetchInstrumentationHandler(handlerData => {
|
|
43
|
+
addFetchInstrumentationHandler((handlerData) => {
|
|
60
44
|
const client = getClient();
|
|
61
45
|
const { propagateTraceparent } = client?.getOptions() || {};
|
|
62
46
|
if (!client || !HAS_CLIENT_MAP.get(client)) {
|
|
63
47
|
return;
|
|
64
48
|
}
|
|
65
|
-
|
|
66
49
|
if (isSentryRequestUrl(handlerData.fetchData.url, client)) {
|
|
67
50
|
return;
|
|
68
51
|
}
|
|
69
|
-
|
|
70
52
|
instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {
|
|
71
|
-
spanOrigin:
|
|
72
|
-
propagateTraceparent
|
|
53
|
+
spanOrigin: "auto.http.fetch",
|
|
54
|
+
propagateTraceparent
|
|
73
55
|
});
|
|
74
|
-
|
|
75
56
|
if (breadcrumbs) {
|
|
76
57
|
createBreadcrumb(handlerData);
|
|
77
58
|
}
|
|
@@ -79,68 +60,55 @@ const _fetchIntegration = ((options = {}) => {
|
|
|
79
60
|
},
|
|
80
61
|
setup(client) {
|
|
81
62
|
HAS_CLIENT_MAP.set(client, true);
|
|
82
|
-
}
|
|
63
|
+
}
|
|
83
64
|
};
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Creates spans and attaches tracing headers to fetch requests.
|
|
88
|
-
*/
|
|
65
|
+
});
|
|
89
66
|
const fetchIntegration = defineIntegration(_fetchIntegration);
|
|
90
|
-
|
|
91
67
|
function createBreadcrumb(handlerData) {
|
|
92
68
|
const { startTimestamp, endTimestamp } = handlerData;
|
|
93
|
-
|
|
94
|
-
// We only capture complete fetch requests
|
|
95
69
|
if (!endTimestamp) {
|
|
96
70
|
return;
|
|
97
71
|
}
|
|
98
|
-
|
|
99
72
|
const breadcrumbData = {
|
|
100
73
|
method: handlerData.fetchData.method,
|
|
101
|
-
url: handlerData.fetchData.url
|
|
74
|
+
url: handlerData.fetchData.url
|
|
102
75
|
};
|
|
103
|
-
|
|
104
76
|
if (handlerData.error) {
|
|
105
77
|
const hint = {
|
|
106
78
|
data: handlerData.error,
|
|
107
79
|
input: handlerData.args,
|
|
108
80
|
startTimestamp,
|
|
109
|
-
endTimestamp
|
|
81
|
+
endTimestamp
|
|
110
82
|
};
|
|
111
|
-
|
|
112
83
|
addBreadcrumb(
|
|
113
84
|
{
|
|
114
|
-
category:
|
|
85
|
+
category: "fetch",
|
|
115
86
|
data: breadcrumbData,
|
|
116
|
-
level:
|
|
117
|
-
type:
|
|
87
|
+
level: "error",
|
|
88
|
+
type: "http"
|
|
118
89
|
},
|
|
119
|
-
hint
|
|
90
|
+
hint
|
|
120
91
|
);
|
|
121
92
|
} else {
|
|
122
|
-
const response = handlerData.response
|
|
123
|
-
|
|
93
|
+
const response = handlerData.response;
|
|
124
94
|
breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;
|
|
125
95
|
breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;
|
|
126
96
|
breadcrumbData.status_code = response?.status;
|
|
127
|
-
|
|
128
97
|
const hint = {
|
|
129
98
|
input: handlerData.args,
|
|
130
99
|
response,
|
|
131
100
|
startTimestamp,
|
|
132
|
-
endTimestamp
|
|
101
|
+
endTimestamp
|
|
133
102
|
};
|
|
134
103
|
const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);
|
|
135
|
-
|
|
136
104
|
addBreadcrumb(
|
|
137
105
|
{
|
|
138
|
-
category:
|
|
106
|
+
category: "fetch",
|
|
139
107
|
data: breadcrumbData,
|
|
140
|
-
type:
|
|
141
|
-
level
|
|
108
|
+
type: "http",
|
|
109
|
+
level
|
|
142
110
|
},
|
|
143
|
-
hint
|
|
111
|
+
hint
|
|
144
112
|
);
|
|
145
113
|
}
|
|
146
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.js","sources":["../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch';\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n }, true);\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAA,GAAmB,
|
|
1
|
+
{"version":3,"file":"fetch.js","sources":["../../../src/integrations/fetch.ts"],"sourcesContent":["import type {\n Client,\n FetchBreadcrumbData,\n FetchBreadcrumbHint,\n HandlerDataFetch,\n IntegrationFn,\n Span,\n} from '@sentry/core';\nimport {\n addBreadcrumb,\n addFetchInstrumentationHandler,\n defineIntegration,\n getBreadcrumbLogLevelFromHttpStatusCode,\n getClient,\n instrumentFetchRequest,\n isSentryRequestUrl,\n LRUMap,\n stringMatchesSomePattern,\n} from '@sentry/core';\n\nconst INTEGRATION_NAME = 'Fetch';\n\nconst HAS_CLIENT_MAP = new WeakMap<Client, boolean>();\n\nexport interface Options {\n /**\n * Whether breadcrumbs should be recorded for requests\n * Defaults to true\n */\n breadcrumbs: boolean;\n\n /**\n * Function determining whether or not to create spans to track outgoing requests to the given URL.\n * By default, spans will be created for all outgoing requests.\n */\n shouldCreateSpanForRequest?: (url: string) => boolean;\n}\n\nconst _fetchIntegration = ((options: Partial<Options> = {}) => {\n const breadcrumbs = options.breadcrumbs === undefined ? true : options.breadcrumbs;\n const shouldCreateSpanForRequest = options.shouldCreateSpanForRequest;\n\n const _createSpanUrlMap = new LRUMap<string, boolean>(100);\n const _headersUrlMap = new LRUMap<string, boolean>(100);\n\n const spans: Record<string, Span> = {};\n\n /** Decides whether to attach trace data to the outgoing fetch request */\n function _shouldAttachTraceData(url: string): boolean {\n const client = getClient();\n\n if (!client) {\n return false;\n }\n\n const clientOptions = client.getOptions();\n\n if (clientOptions.tracePropagationTargets === undefined) {\n return true;\n }\n\n const cachedDecision = _headersUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = stringMatchesSomePattern(url, clientOptions.tracePropagationTargets);\n _headersUrlMap.set(url, decision);\n return decision;\n }\n\n /** Helper that wraps shouldCreateSpanForRequest option */\n function _shouldCreateSpan(url: string): boolean {\n if (shouldCreateSpanForRequest === undefined) {\n return true;\n }\n\n const cachedDecision = _createSpanUrlMap.get(url);\n if (cachedDecision !== undefined) {\n return cachedDecision;\n }\n\n const decision = shouldCreateSpanForRequest(url);\n _createSpanUrlMap.set(url, decision);\n return decision;\n }\n\n return {\n name: INTEGRATION_NAME,\n setupOnce() {\n addFetchInstrumentationHandler(handlerData => {\n const client = getClient();\n const { propagateTraceparent } = client?.getOptions() || {};\n if (!client || !HAS_CLIENT_MAP.get(client)) {\n return;\n }\n\n if (isSentryRequestUrl(handlerData.fetchData.url, client)) {\n return;\n }\n\n instrumentFetchRequest(handlerData, _shouldCreateSpan, _shouldAttachTraceData, spans, {\n spanOrigin: 'auto.http.fetch',\n propagateTraceparent,\n });\n\n if (breadcrumbs) {\n createBreadcrumb(handlerData);\n }\n }, true);\n },\n setup(client) {\n HAS_CLIENT_MAP.set(client, true);\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Creates spans and attaches tracing headers to fetch requests.\n */\nexport const fetchIntegration = defineIntegration(_fetchIntegration);\n\nfunction createBreadcrumb(handlerData: HandlerDataFetch): void {\n const { startTimestamp, endTimestamp } = handlerData;\n\n // We only capture complete fetch requests\n if (!endTimestamp) {\n return;\n }\n\n const breadcrumbData: FetchBreadcrumbData = {\n method: handlerData.fetchData.method,\n url: handlerData.fetchData.url,\n };\n\n if (handlerData.error) {\n const hint: FetchBreadcrumbHint = {\n data: handlerData.error,\n input: handlerData.args,\n startTimestamp,\n endTimestamp,\n };\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n level: 'error',\n type: 'http',\n },\n hint,\n );\n } else {\n const response = handlerData.response as Response | undefined;\n\n breadcrumbData.request_body_size = handlerData.fetchData.request_body_size;\n breadcrumbData.response_body_size = handlerData.fetchData.response_body_size;\n breadcrumbData.status_code = response?.status;\n\n const hint: FetchBreadcrumbHint = {\n input: handlerData.args,\n response,\n startTimestamp,\n endTimestamp,\n };\n const level = getBreadcrumbLogLevelFromHttpStatusCode(breadcrumbData.status_code);\n\n addBreadcrumb(\n {\n category: 'fetch',\n data: breadcrumbData,\n type: 'http',\n level,\n },\n hint,\n );\n }\n}\n"],"names":[],"mappings":";;AAoBA,MAAM,gBAAA,GAAmB,OAAA;AAEzB,MAAM,cAAA,uBAAqB,OAAA,EAAyB;AAgBpD,MAAM,iBAAA,IAAqB,CAAC,OAAA,GAA4B,EAAC,KAAM;AAC7D,EAAA,MAAM,WAAA,GAAc,OAAA,CAAQ,WAAA,KAAgB,MAAA,GAAY,OAAO,OAAA,CAAQ,WAAA;AACvE,EAAA,MAAM,6BAA6B,OAAA,CAAQ,0BAAA;AAE3C,EAAA,MAAM,iBAAA,GAAoB,IAAI,MAAA,CAAwB,GAAG,CAAA;AACzD,EAAA,MAAM,cAAA,GAAiB,IAAI,MAAA,CAAwB,GAAG,CAAA;AAEtD,EAAA,MAAM,QAA8B,EAAC;AAGrC,EAAA,SAAS,uBAAuB,GAAA,EAAsB;AACpD,IAAA,MAAM,SAAS,SAAA,EAAU;AAEzB,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,OAAO,KAAA;AAAA,IACT;AAEA,IAAA,MAAM,aAAA,GAAgB,OAAO,UAAA,EAAW;AAExC,IAAA,IAAI,aAAA,CAAc,4BAA4B,MAAA,EAAW;AACvD,MAAA,OAAO,IAAA;AAAA,IACT;AAEA,IAAA,MAAM,cAAA,GAAiB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IAAA,MAAM,IAAA,GAA4B;AAAA,MAChC,OAAO,WAAA,CAAY,IAAA;AAAA,MACnB,QAAA;AAAA,MACA,cAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,MAAM,KAAA,GAAQ,uCAAA,CAAwC,cAAA,CAAe,WAAW,CAAA;AAEhF,IAAA,aAAA;AAAA,MACE;AAAA,QACE,QAAA,EAAU,OAAA;AAAA,QACV,IAAA,EAAM,cAAA;AAAA,QACN,IAAA,EAAM,MAAA;AAAA,QACN;AAAA,OACF;AAAA,MACA;AAAA,KACF;AAAA,EACF;AACF;;;;"}
|
|
@@ -1,78 +1,47 @@
|
|
|
1
1
|
import { defineIntegration, debug, getActiveSpan, updateSpanName, getRootSpan, getIsolationScope, captureException, getClient } from '@sentry/core';
|
|
2
2
|
import { DEBUG_BUILD } from '../debug-build.js';
|
|
3
3
|
|
|
4
|
-
const INTEGRATION_NAME =
|
|
5
|
-
|
|
6
|
-
/** Only exported for internal use */
|
|
4
|
+
const INTEGRATION_NAME = "Hono";
|
|
7
5
|
function getHonoIntegration() {
|
|
8
6
|
return getClient()?.getIntegrationByName(INTEGRATION_NAME);
|
|
9
7
|
}
|
|
10
|
-
|
|
11
8
|
function isHonoError(err) {
|
|
12
9
|
if (err instanceof Error) {
|
|
13
10
|
return true;
|
|
14
11
|
}
|
|
15
|
-
return typeof err ===
|
|
12
|
+
return typeof err === "object" && err !== null && "status" in err;
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
// Vendored from https://github.com/honojs/hono/blob/d3abeb1f801aaa1b334285c73da5f5f022dbcadb/src/helper/route/index.ts#L58-L59
|
|
19
|
-
const routePath = (c) => c.req?.path ?? '';
|
|
20
|
-
|
|
14
|
+
const routePath = (c) => c.req?.path ?? "";
|
|
21
15
|
const _honoIntegration = ((options = {}) => {
|
|
22
16
|
return {
|
|
23
17
|
name: INTEGRATION_NAME,
|
|
24
18
|
// Hono error handler: https://github.com/honojs/hono/blob/d3abeb1f801aaa1b334285c73da5f5f022dbcadb/src/hono-base.ts#L35
|
|
25
19
|
handleHonoException(err, context) {
|
|
26
20
|
const shouldHandleError = options.shouldHandleError || defaultShouldHandleError;
|
|
27
|
-
|
|
28
21
|
if (!isHonoError(err)) {
|
|
29
22
|
DEBUG_BUILD && debug.log("[Hono] Won't capture exception in `onError` because it's not a Hono error.", err);
|
|
30
23
|
return;
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
if (shouldHandleError(err)) {
|
|
34
26
|
if (context) {
|
|
35
27
|
const activeSpan = getActiveSpan();
|
|
36
28
|
const spanName = `${context.req.method} ${routePath(context)}`;
|
|
37
|
-
|
|
38
29
|
if (activeSpan) {
|
|
39
30
|
activeSpan.updateName(spanName);
|
|
40
31
|
updateSpanName(getRootSpan(activeSpan), spanName);
|
|
41
32
|
}
|
|
42
|
-
|
|
43
33
|
getIsolationScope().setTransactionName(spanName);
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
captureException(err, { mechanism: { handled: false, type: 'auto.faas.hono.error_handler' } });
|
|
35
|
+
captureException(err, { mechanism: { handled: false, type: "auto.faas.hono.error_handler" } });
|
|
47
36
|
} else {
|
|
48
|
-
DEBUG_BUILD && debug.log(
|
|
37
|
+
DEBUG_BUILD && debug.log("[Hono] Not capturing exception because `shouldHandleError` returned `false`.", err);
|
|
49
38
|
}
|
|
50
|
-
}
|
|
39
|
+
}
|
|
51
40
|
};
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Automatically captures exceptions caught with the `onError` handler in Hono.
|
|
56
|
-
*
|
|
57
|
-
* The integration is enabled by default.
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* integrations: [
|
|
61
|
-
* honoIntegration({
|
|
62
|
-
* shouldHandleError: (err) => true; // always capture exceptions in onError
|
|
63
|
-
* })
|
|
64
|
-
* ]
|
|
65
|
-
*/
|
|
41
|
+
});
|
|
66
42
|
const honoIntegration = defineIntegration(_honoIntegration);
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Default function to determine if an error should be sent to Sentry
|
|
70
|
-
*
|
|
71
|
-
* 3xx and 4xx errors are not sent by default.
|
|
72
|
-
*/
|
|
73
43
|
function defaultShouldHandleError(error) {
|
|
74
44
|
const statusCode = error?.status;
|
|
75
|
-
// 3xx and 4xx errors are not sent by default.
|
|
76
45
|
return statusCode ? statusCode >= 500 || statusCode <= 299 : true;
|
|
77
46
|
}
|
|
78
47
|
|