@sentry/cloudflare 10.42.0 → 10.44.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/index.js +3 -2
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +7 -2
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentEmail.js +80 -0
- package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentFetch.js +36 -0
- package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentQueue.js +85 -0
- package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentScheduled.js +82 -0
- package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentTail.js +63 -0
- package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/cjs/request.js +1 -1
- package/build/cjs/request.js.map +1 -1
- package/build/cjs/withSentry.js +66 -0
- package/build/cjs/withSentry.js.map +1 -0
- package/build/cjs/wrapMethodWithSentry.js +7 -3
- package/build/cjs/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/index.js +2 -2
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js +7 -2
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentEmail.js +78 -0
- package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentFetch.js +34 -0
- package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentQueue.js +83 -0
- package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentScheduled.js +80 -0
- package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentTail.js +61 -0
- package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/request.js +1 -1
- package/build/esm/request.js.map +1 -1
- package/build/esm/withSentry.js +64 -0
- package/build/esm/withSentry.js.map +1 -0
- package/build/esm/wrapMethodWithSentry.js +7 -3
- package/build/esm/wrapMethodWithSentry.js.map +1 -1
- package/build/types/index.d.ts +2 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEmail.d.ts +7 -0
- package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentFetch.d.ts +7 -0
- package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentQueue.d.ts +7 -0
- package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts +7 -0
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentTail.d.ts +7 -0
- package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -0
- package/build/types/{handler.d.ts → withSentry.d.ts} +1 -1
- package/build/types/withSentry.d.ts.map +1 -0
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/build/types-ts3.8/index.d.ts +2 -2
- package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +7 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +7 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +7 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +7 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +7 -0
- package/build/types-ts3.8/{handler.d.ts → withSentry.d.ts} +1 -1
- package/package.json +4 -4
- package/build/cjs/handler.js +0 -251
- package/build/cjs/handler.js.map +0 -1
- package/build/esm/handler.js +0 -249
- package/build/esm/handler.js.map +0 -1
- package/build/types/handler.d.ts.map +0 -1
package/build/cjs/handler.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sources":["../../src/handler.ts"],"sourcesContent":["import {\n captureException,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { getHonoIntegration } from './integrations/hono';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandler } from './request';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\n// eslint-disable-next-line complexity\nexport function withSentry<\n Env = unknown,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> = ExportedHandler<\n Env,\n QueueHandlerMessage,\n CfHostMetadata\n >,\n>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T {\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {\n handler.fetch = new Proxy(handler.fetch, {\n apply(target, thisArg, args: Parameters<ExportedHandlerFetchHandler<Env, CfHostMetadata>>) {\n const [request, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n const options = getFinalOptions(optionsCallback(env), env);\n\n return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));\n },\n });\n\n markAsInstrumented(handler.fetch);\n }\n\n /* Hono does not reach the catch block of the fetch handler and captureException needs to be called in the hono errorHandler */\n if (\n 'onError' in handler &&\n 'errorHandler' in handler &&\n typeof handler.errorHandler === 'function' &&\n !isInstrumented(handler.errorHandler)\n ) {\n handler.errorHandler = new Proxy(handler.errorHandler, {\n apply(target, thisArg, args) {\n const [err, context] = args;\n\n getHonoIntegration()?.handleHonoException(err, context);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n markAsInstrumented(handler.errorHandler);\n }\n\n if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {\n handler.scheduled = new Proxy(handler.scheduled, {\n apply(target, thisArg, args: Parameters<ExportedHandlerScheduledHandler<Env>>) {\n const [event, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\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 ${event.cron}`,\n attributes: {\n 'faas.cron': event.cron,\n 'faas.time': new Date(event.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 (target.apply(thisArg, args) as ReturnType<typeof target>);\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 markAsInstrumented(handler.scheduled);\n }\n\n if ('email' in handler && typeof handler.email === 'function' && !isInstrumented(handler.email)) {\n handler.email = new Proxy(handler.email, {\n apply(target, thisArg, args: Parameters<EmailExportedHandler<Env>>) {\n const [emailMessage, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\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.email',\n name: `Handle Email ${emailMessage.to}`,\n attributes: {\n 'faas.trigger': 'email',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.email',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await (target.apply(thisArg, args) as ReturnType<typeof target>);\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.email' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.email);\n }\n\n if ('queue' in handler && typeof handler.queue === 'function' && !isInstrumented(handler.queue)) {\n handler.queue = new Proxy(handler.queue, {\n apply(target, thisArg, args: Parameters<ExportedHandlerQueueHandler<Env, QueueHandlerMessage>>) {\n const [batch, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\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.queue',\n name: `process ${batch.queue}`,\n attributes: {\n 'faas.trigger': 'pubsub',\n 'messaging.destination.name': batch.queue,\n 'messaging.system': 'cloudflare',\n 'messaging.batch.message_count': batch.messages.length,\n 'messaging.message.retry.count': batch.messages.reduce(\n (acc, message) => acc + message.attempts - 1,\n 0,\n ),\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'queue.process',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.queue',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await (target.apply(thisArg, args) as ReturnType<typeof target>);\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.queue' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.queue);\n }\n\n if ('tail' in handler && typeof handler.tail === 'function' && !isInstrumented(handler.tail)) {\n handler.tail = new Proxy(handler.tail, {\n apply(target, thisArg, args: Parameters<ExportedHandlerTailHandler<Env>>) {\n const [, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(async isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\n\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 (target.apply(thisArg, args) as ReturnType<typeof target>);\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 markAsInstrumented(handler.tail);\n }\n\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n"],"names":["setAsyncLocalStorageAsyncContextStrategy","isInstrumented","request","instrumentContext","options","getFinalOptions","wrapRequestHandler","markAsInstrumented","getHonoIntegration","withIsolationScope","init","addCloudResourceContext","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","captureException","flushAndDispose","SEMANTIC_ATTRIBUTE_SENTRY_OP"],"mappings":";;;;;;;;;;;;;AAmBA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_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, captureException, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
|
|
2
|
-
import { setAsyncLocalStorageAsyncContextStrategy } from './async.js';
|
|
3
|
-
import { flushAndDispose } from './flush.js';
|
|
4
|
-
import { isInstrumented, markAsInstrumented } from './instrument.js';
|
|
5
|
-
import { getHonoIntegration } from './integrations/hono.js';
|
|
6
|
-
import { getFinalOptions } from './options.js';
|
|
7
|
-
import { wrapRequestHandler } from './request.js';
|
|
8
|
-
import { addCloudResourceContext } from './scope-utils.js';
|
|
9
|
-
import { init } from './sdk.js';
|
|
10
|
-
import { instrumentContext } from './utils/instrumentContext.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Wrapper for Cloudflare handlers.
|
|
14
|
-
*
|
|
15
|
-
* Initializes the SDK and wraps the handler with Sentry instrumentation.
|
|
16
|
-
*
|
|
17
|
-
* Automatically instruments the `fetch` method of the handler.
|
|
18
|
-
*
|
|
19
|
-
* @param optionsCallback Function that returns the options for the SDK initialization.
|
|
20
|
-
* @param handler {ExportedHandler} The handler to wrap.
|
|
21
|
-
* @returns The wrapped handler.
|
|
22
|
-
*/
|
|
23
|
-
// eslint-disable-next-line complexity
|
|
24
|
-
function withSentry
|
|
25
|
-
|
|
26
|
-
(optionsCallback, handler) {
|
|
27
|
-
setAsyncLocalStorageAsyncContextStrategy();
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {
|
|
31
|
-
handler.fetch = new Proxy(handler.fetch, {
|
|
32
|
-
apply(target, thisArg, args) {
|
|
33
|
-
const [request, env, ctx] = args;
|
|
34
|
-
const context = instrumentContext(ctx);
|
|
35
|
-
args[2] = context;
|
|
36
|
-
|
|
37
|
-
const options = getFinalOptions(optionsCallback(env), env);
|
|
38
|
-
|
|
39
|
-
return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
markAsInstrumented(handler.fetch);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/* Hono does not reach the catch block of the fetch handler and captureException needs to be called in the hono errorHandler */
|
|
47
|
-
if (
|
|
48
|
-
'onError' in handler &&
|
|
49
|
-
'errorHandler' in handler &&
|
|
50
|
-
typeof handler.errorHandler === 'function' &&
|
|
51
|
-
!isInstrumented(handler.errorHandler)
|
|
52
|
-
) {
|
|
53
|
-
handler.errorHandler = new Proxy(handler.errorHandler, {
|
|
54
|
-
apply(target, thisArg, args) {
|
|
55
|
-
const [err, context] = args;
|
|
56
|
-
|
|
57
|
-
getHonoIntegration()?.handleHonoException(err, context);
|
|
58
|
-
|
|
59
|
-
return Reflect.apply(target, thisArg, args);
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
markAsInstrumented(handler.errorHandler);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {
|
|
67
|
-
handler.scheduled = new Proxy(handler.scheduled, {
|
|
68
|
-
apply(target, thisArg, args) {
|
|
69
|
-
const [event, env, ctx] = args;
|
|
70
|
-
const context = instrumentContext(ctx);
|
|
71
|
-
args[2] = context;
|
|
72
|
-
|
|
73
|
-
return withIsolationScope(isolationScope => {
|
|
74
|
-
const options = getFinalOptions(optionsCallback(env), env);
|
|
75
|
-
const waitUntil = context.waitUntil.bind(context);
|
|
76
|
-
|
|
77
|
-
const client = init({ ...options, ctx: context });
|
|
78
|
-
isolationScope.setClient(client);
|
|
79
|
-
|
|
80
|
-
addCloudResourceContext(isolationScope);
|
|
81
|
-
|
|
82
|
-
return startSpan(
|
|
83
|
-
{
|
|
84
|
-
op: 'faas.cron',
|
|
85
|
-
name: `Scheduled Cron ${event.cron}`,
|
|
86
|
-
attributes: {
|
|
87
|
-
'faas.cron': event.cron,
|
|
88
|
-
'faas.time': new Date(event.scheduledTime).toISOString(),
|
|
89
|
-
'faas.trigger': 'timer',
|
|
90
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.scheduled',
|
|
91
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
async () => {
|
|
95
|
-
try {
|
|
96
|
-
return await (target.apply(thisArg, args) );
|
|
97
|
-
} catch (e) {
|
|
98
|
-
captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.scheduled' } });
|
|
99
|
-
throw e;
|
|
100
|
-
} finally {
|
|
101
|
-
waitUntil(flushAndDispose(client));
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
);
|
|
105
|
-
});
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
markAsInstrumented(handler.scheduled);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if ('email' in handler && typeof handler.email === 'function' && !isInstrumented(handler.email)) {
|
|
113
|
-
handler.email = new Proxy(handler.email, {
|
|
114
|
-
apply(target, thisArg, args) {
|
|
115
|
-
const [emailMessage, env, ctx] = args;
|
|
116
|
-
const context = instrumentContext(ctx);
|
|
117
|
-
args[2] = context;
|
|
118
|
-
|
|
119
|
-
return withIsolationScope(isolationScope => {
|
|
120
|
-
const options = getFinalOptions(optionsCallback(env), env);
|
|
121
|
-
const waitUntil = context.waitUntil.bind(context);
|
|
122
|
-
|
|
123
|
-
const client = init({ ...options, ctx: context });
|
|
124
|
-
isolationScope.setClient(client);
|
|
125
|
-
|
|
126
|
-
addCloudResourceContext(isolationScope);
|
|
127
|
-
|
|
128
|
-
return startSpan(
|
|
129
|
-
{
|
|
130
|
-
op: 'faas.email',
|
|
131
|
-
name: `Handle Email ${emailMessage.to}`,
|
|
132
|
-
attributes: {
|
|
133
|
-
'faas.trigger': 'email',
|
|
134
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.email',
|
|
135
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
async () => {
|
|
139
|
-
try {
|
|
140
|
-
return await (target.apply(thisArg, args) );
|
|
141
|
-
} catch (e) {
|
|
142
|
-
captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.email' } });
|
|
143
|
-
throw e;
|
|
144
|
-
} finally {
|
|
145
|
-
waitUntil(flushAndDispose(client));
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
|
-
);
|
|
149
|
-
});
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
markAsInstrumented(handler.email);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if ('queue' in handler && typeof handler.queue === 'function' && !isInstrumented(handler.queue)) {
|
|
157
|
-
handler.queue = new Proxy(handler.queue, {
|
|
158
|
-
apply(target, thisArg, args) {
|
|
159
|
-
const [batch, env, ctx] = args;
|
|
160
|
-
const context = instrumentContext(ctx);
|
|
161
|
-
args[2] = context;
|
|
162
|
-
|
|
163
|
-
return withIsolationScope(isolationScope => {
|
|
164
|
-
const options = getFinalOptions(optionsCallback(env), env);
|
|
165
|
-
const waitUntil = context.waitUntil.bind(context);
|
|
166
|
-
|
|
167
|
-
const client = init({ ...options, ctx: context });
|
|
168
|
-
isolationScope.setClient(client);
|
|
169
|
-
|
|
170
|
-
addCloudResourceContext(isolationScope);
|
|
171
|
-
|
|
172
|
-
return startSpan(
|
|
173
|
-
{
|
|
174
|
-
op: 'faas.queue',
|
|
175
|
-
name: `process ${batch.queue}`,
|
|
176
|
-
attributes: {
|
|
177
|
-
'faas.trigger': 'pubsub',
|
|
178
|
-
'messaging.destination.name': batch.queue,
|
|
179
|
-
'messaging.system': 'cloudflare',
|
|
180
|
-
'messaging.batch.message_count': batch.messages.length,
|
|
181
|
-
'messaging.message.retry.count': batch.messages.reduce(
|
|
182
|
-
(acc, message) => acc + message.attempts - 1,
|
|
183
|
-
0,
|
|
184
|
-
),
|
|
185
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'queue.process',
|
|
186
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.queue',
|
|
187
|
-
[SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
async () => {
|
|
191
|
-
try {
|
|
192
|
-
return await (target.apply(thisArg, args) );
|
|
193
|
-
} catch (e) {
|
|
194
|
-
captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.queue' } });
|
|
195
|
-
throw e;
|
|
196
|
-
} finally {
|
|
197
|
-
waitUntil(flushAndDispose(client));
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
|
-
},
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
markAsInstrumented(handler.queue);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if ('tail' in handler && typeof handler.tail === 'function' && !isInstrumented(handler.tail)) {
|
|
209
|
-
handler.tail = new Proxy(handler.tail, {
|
|
210
|
-
apply(target, thisArg, args) {
|
|
211
|
-
const [, env, ctx] = args;
|
|
212
|
-
const context = instrumentContext(ctx);
|
|
213
|
-
args[2] = context;
|
|
214
|
-
|
|
215
|
-
return withIsolationScope(async isolationScope => {
|
|
216
|
-
const options = getFinalOptions(optionsCallback(env), env);
|
|
217
|
-
|
|
218
|
-
const waitUntil = context.waitUntil.bind(context);
|
|
219
|
-
|
|
220
|
-
const client = init({ ...options, ctx: context });
|
|
221
|
-
isolationScope.setClient(client);
|
|
222
|
-
|
|
223
|
-
addCloudResourceContext(isolationScope);
|
|
224
|
-
|
|
225
|
-
try {
|
|
226
|
-
return await (target.apply(thisArg, args) );
|
|
227
|
-
} catch (e) {
|
|
228
|
-
captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.tail' } });
|
|
229
|
-
throw e;
|
|
230
|
-
} finally {
|
|
231
|
-
waitUntil(flushAndDispose(client));
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
},
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
markAsInstrumented(handler.tail);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// This is here because Miniflare sometimes cannot get instrumented
|
|
241
|
-
} catch {
|
|
242
|
-
// Do not console anything here, we don't want to spam the console with errors
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return handler;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export { withSentry };
|
|
249
|
-
//# sourceMappingURL=handler.js.map
|
package/build/esm/handler.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sources":["../../src/handler.ts"],"sourcesContent":["import {\n captureException,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,\n startSpan,\n withIsolationScope,\n} from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { getHonoIntegration } from './integrations/hono';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandler } from './request';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\n\n/**\n * Wrapper for Cloudflare handlers.\n *\n * Initializes the SDK and wraps the handler with Sentry instrumentation.\n *\n * Automatically instruments the `fetch` method of the handler.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param handler {ExportedHandler} The handler to wrap.\n * @returns The wrapped handler.\n */\n// eslint-disable-next-line complexity\nexport function withSentry<\n Env = unknown,\n QueueHandlerMessage = unknown,\n CfHostMetadata = unknown,\n T extends ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> = ExportedHandler<\n Env,\n QueueHandlerMessage,\n CfHostMetadata\n >,\n>(optionsCallback: (env: Env) => CloudflareOptions | undefined, handler: T): T {\n setAsyncLocalStorageAsyncContextStrategy();\n\n try {\n if ('fetch' in handler && typeof handler.fetch === 'function' && !isInstrumented(handler.fetch)) {\n handler.fetch = new Proxy(handler.fetch, {\n apply(target, thisArg, args: Parameters<ExportedHandlerFetchHandler<Env, CfHostMetadata>>) {\n const [request, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n const options = getFinalOptions(optionsCallback(env), env);\n\n return wrapRequestHandler({ options, request, context }, () => target.apply(thisArg, args));\n },\n });\n\n markAsInstrumented(handler.fetch);\n }\n\n /* Hono does not reach the catch block of the fetch handler and captureException needs to be called in the hono errorHandler */\n if (\n 'onError' in handler &&\n 'errorHandler' in handler &&\n typeof handler.errorHandler === 'function' &&\n !isInstrumented(handler.errorHandler)\n ) {\n handler.errorHandler = new Proxy(handler.errorHandler, {\n apply(target, thisArg, args) {\n const [err, context] = args;\n\n getHonoIntegration()?.handleHonoException(err, context);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n\n markAsInstrumented(handler.errorHandler);\n }\n\n if ('scheduled' in handler && typeof handler.scheduled === 'function' && !isInstrumented(handler.scheduled)) {\n handler.scheduled = new Proxy(handler.scheduled, {\n apply(target, thisArg, args: Parameters<ExportedHandlerScheduledHandler<Env>>) {\n const [event, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\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 ${event.cron}`,\n attributes: {\n 'faas.cron': event.cron,\n 'faas.time': new Date(event.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 (target.apply(thisArg, args) as ReturnType<typeof target>);\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 markAsInstrumented(handler.scheduled);\n }\n\n if ('email' in handler && typeof handler.email === 'function' && !isInstrumented(handler.email)) {\n handler.email = new Proxy(handler.email, {\n apply(target, thisArg, args: Parameters<EmailExportedHandler<Env>>) {\n const [emailMessage, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\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.email',\n name: `Handle Email ${emailMessage.to}`,\n attributes: {\n 'faas.trigger': 'email',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.email',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await (target.apply(thisArg, args) as ReturnType<typeof target>);\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.email' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.email);\n }\n\n if ('queue' in handler && typeof handler.queue === 'function' && !isInstrumented(handler.queue)) {\n handler.queue = new Proxy(handler.queue, {\n apply(target, thisArg, args: Parameters<ExportedHandlerQueueHandler<Env, QueueHandlerMessage>>) {\n const [batch, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\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.queue',\n name: `process ${batch.queue}`,\n attributes: {\n 'faas.trigger': 'pubsub',\n 'messaging.destination.name': batch.queue,\n 'messaging.system': 'cloudflare',\n 'messaging.batch.message_count': batch.messages.length,\n 'messaging.message.retry.count': batch.messages.reduce(\n (acc, message) => acc + message.attempts - 1,\n 0,\n ),\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'queue.process',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.queue',\n [SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',\n },\n },\n async () => {\n try {\n return await (target.apply(thisArg, args) as ReturnType<typeof target>);\n } catch (e) {\n captureException(e, { mechanism: { handled: false, type: 'auto.faas.cloudflare.queue' } });\n throw e;\n } finally {\n waitUntil(flushAndDispose(client));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.queue);\n }\n\n if ('tail' in handler && typeof handler.tail === 'function' && !isInstrumented(handler.tail)) {\n handler.tail = new Proxy(handler.tail, {\n apply(target, thisArg, args: Parameters<ExportedHandlerTailHandler<Env>>) {\n const [, env, ctx] = args;\n const context = instrumentContext(ctx);\n args[2] = context;\n\n return withIsolationScope(async isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\n\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 (target.apply(thisArg, args) as ReturnType<typeof target>);\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 markAsInstrumented(handler.tail);\n }\n\n // This is here because Miniflare sometimes cannot get instrumented\n } catch {\n // Do not console anything here, we don't want to spam the console with errors\n }\n\n return handler;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS;;AAShB,CAAE,eAAe,EAA+C,OAAO,EAAQ;AAC/E,EAAE,wCAAwC,EAAE;;AAE5C,EAAE,IAAI;AACN,IAAI,IAAI,OAAA,IAAW,WAAW,OAAO,OAAO,CAAC,KAAA,KAAU,UAAA,IAAc,CAAC,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACrG,MAAM,OAAO,CAAC,KAAA,GAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE;AAC/C,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAgE;AACnG,UAAU,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,CAAA,GAAI,IAAI;AAC1C,UAAU,MAAM,OAAA,GAAU,iBAAiB,CAAC,GAAG,CAAC;AAChD,UAAU,IAAI,CAAC,CAAC,CAAA,GAAI,OAAO;;AAE3B,UAAU,MAAM,OAAA,GAAU,eAAe,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC;;AAEpE,UAAU,OAAO,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAA,EAAS,EAAE,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACrG,QAAQ,CAAC;AACT,OAAO,CAAC;;AAER,MAAM,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC;AACvC,IAAI;;AAEJ;AACA,IAAI;AACJ,MAAM,SAAA,IAAa,OAAA;AACnB,MAAM,cAAA,IAAkB,OAAA;AACxB,MAAM,OAAO,OAAO,CAAC,YAAA,KAAiB,UAAA;AACtC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,YAAY;AAC1C,MAAM;AACN,MAAM,OAAO,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