@sentry/cloudflare 10.47.0 → 10.49.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/client.js.map +1 -1
- package/build/cjs/durableobject.js +42 -16
- package/build/cjs/durableobject.js.map +1 -1
- package/build/cjs/index.js +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrument.js +72 -8
- package/build/cjs/instrument.js.map +1 -1
- package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js +56 -0
- package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +38 -3
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js +101 -0
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentEmail.js +16 -13
- package/build/cjs/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentEnv.js +83 -0
- package/build/cjs/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentFetch.js +36 -10
- package/build/cjs/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentFetcher.js +38 -0
- package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/cjs/instrumentations/worker/instrumentQueue.js +36 -10
- package/build/cjs/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentScheduled.js +36 -13
- package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/cjs/instrumentations/worker/instrumentTail.js +34 -10
- package/build/cjs/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/cjs/integrations/tracing/vercelai.js +2 -1
- package/build/cjs/integrations/tracing/vercelai.js.map +1 -1
- package/build/cjs/request.js +5 -6
- package/build/cjs/request.js.map +1 -1
- package/build/cjs/scope-utils.js.map +1 -1
- package/build/cjs/sdk.js +6 -1
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/utils/instrumentContext.js +2 -1
- package/build/cjs/utils/instrumentContext.js.map +1 -1
- package/build/cjs/utils/isBinding.js +32 -0
- package/build/cjs/utils/isBinding.js.map +1 -0
- package/build/cjs/utils/isCloudflareClass.js +29 -0
- package/build/cjs/utils/isCloudflareClass.js.map +1 -0
- package/build/cjs/utils/rpcOptions.js +84 -0
- package/build/cjs/utils/rpcOptions.js.map +1 -0
- package/build/cjs/utils/traceLinks.js +78 -0
- package/build/cjs/utils/traceLinks.js.map +1 -0
- package/build/cjs/withSentry.js +31 -20
- package/build/cjs/withSentry.js.map +1 -1
- package/build/cjs/workflows.js +3 -2
- package/build/cjs/workflows.js.map +1 -1
- package/build/cjs/wrapMethodWithSentry.js +157 -112
- package/build/cjs/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/durableobject.js +43 -17
- package/build/esm/durableobject.js.map +1 -1
- package/build/esm/index.js +1 -1
- package/build/esm/instrument.js +71 -8
- package/build/esm/instrument.js.map +1 -1
- package/build/esm/instrumentations/instrumentDurableObjectNamespace.js +54 -0
- package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js +39 -4
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js +99 -0
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentEmail.js +17 -14
- package/build/esm/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentEnv.js +81 -0
- package/build/esm/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentFetch.js +37 -12
- package/build/esm/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentFetcher.js +36 -0
- package/build/esm/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/esm/instrumentations/worker/instrumentQueue.js +37 -12
- package/build/esm/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentScheduled.js +37 -15
- package/build/esm/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/esm/instrumentations/worker/instrumentTail.js +35 -12
- package/build/esm/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/esm/integrations/tracing/vercelai.js +2 -1
- package/build/esm/integrations/tracing/vercelai.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/request.js +5 -6
- package/build/esm/request.js.map +1 -1
- package/build/esm/scope-utils.js.map +1 -1
- package/build/esm/sdk.js +7 -2
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/utils/instrumentContext.js +2 -1
- package/build/esm/utils/instrumentContext.js.map +1 -1
- package/build/esm/utils/isBinding.js +29 -0
- package/build/esm/utils/isBinding.js.map +1 -0
- package/build/esm/utils/isCloudflareClass.js +27 -0
- package/build/esm/utils/isCloudflareClass.js.map +1 -0
- package/build/esm/utils/rpcOptions.js +81 -0
- package/build/esm/utils/rpcOptions.js.map +1 -0
- package/build/esm/utils/traceLinks.js +73 -0
- package/build/esm/utils/traceLinks.js.map +1 -0
- package/build/esm/withSentry.js +32 -21
- package/build/esm/withSentry.js.map +1 -1
- package/build/esm/workflows.js +3 -2
- package/build/esm/workflows.js.map +1 -1
- package/build/esm/wrapMethodWithSentry.js +159 -114
- package/build/esm/wrapMethodWithSentry.js.map +1 -1
- package/build/types/client.d.ts +39 -10
- package/build/types/client.d.ts.map +1 -1
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrument.d.ts +15 -4
- package/build/types/instrument.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts +12 -0
- package/build/types/instrumentations/instrumentDurableObjectNamespace.d.ts.map +1 -0
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts +8 -1
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +42 -0
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -1
- package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEnv.d.ts +16 -0
- package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentFetch.d.ts +6 -1
- package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentFetcher.d.ts +10 -0
- package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -0
- package/build/types/instrumentations/worker/instrumentQueue.d.ts +6 -1
- package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts +6 -1
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentTail.d.ts +6 -1
- package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
- package/build/types/integrations/tracing/vercelai.d.ts +9 -1
- package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
- package/build/types/request.d.ts +3 -3
- package/build/types/request.d.ts.map +1 -1
- package/build/types/scope-utils.d.ts +2 -2
- package/build/types/scope-utils.d.ts.map +1 -1
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/utils/instrumentContext.d.ts.map +1 -1
- package/build/types/utils/isBinding.d.ts +49 -0
- package/build/types/utils/isBinding.d.ts.map +1 -0
- package/build/types/utils/isCloudflareClass.d.ts +30 -0
- package/build/types/utils/isCloudflareClass.d.ts.map +1 -0
- package/build/types/utils/rpcOptions.d.ts +24 -0
- package/build/types/utils/rpcOptions.d.ts.map +1 -0
- package/build/types/utils/traceLinks.d.ts +27 -0
- package/build/types/utils/traceLinks.d.ts.map +1 -0
- package/build/types/withSentry.d.ts +3 -2
- package/build/types/withSentry.d.ts.map +1 -1
- package/build/types/workflows.d.ts.map +1 -1
- package/build/types/wrapMethodWithSentry.d.ts +19 -2
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/build/types-ts3.8/client.d.ts +39 -10
- package/build/types-ts3.8/index.d.ts +1 -1
- package/build/types-ts3.8/instrument.d.ts +15 -4
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +12 -0
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +8 -1
- package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +42 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +2 -1
- package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +16 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +6 -1
- package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +10 -0
- package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +6 -1
- package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +6 -1
- package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +6 -1
- package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +9 -1
- package/build/types-ts3.8/request.d.ts +3 -3
- package/build/types-ts3.8/scope-utils.d.ts +2 -2
- package/build/types-ts3.8/utils/isBinding.d.ts +49 -0
- package/build/types-ts3.8/utils/isCloudflareClass.d.ts +30 -0
- package/build/types-ts3.8/utils/rpcOptions.d.ts +24 -0
- package/build/types-ts3.8/utils/traceLinks.d.ts +27 -0
- package/build/types-ts3.8/withSentry.d.ts +3 -2
- package/build/types-ts3.8/wrapMethodWithSentry.d.ts +19 -2
- package/package.json +2 -2
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { getClient,
|
|
1
|
+
import { getClient, withIsolationScope, withScope, isThenable, captureException, SEMANTIC_ATTRIBUTE_SENTRY_OP, startNewTrace, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN } from '@sentry/core';
|
|
2
2
|
import { flushAndDispose } from './flush.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ensureInstrumented } from './instrument.js';
|
|
4
4
|
import { init } from './sdk.js';
|
|
5
|
+
import { storeSpanContext, getStoredSpanContext, buildSpanLinks } from './utils/traceLinks.js';
|
|
5
6
|
|
|
6
7
|
/** Extended DurableObjectState with originalStorage exposed by instrumentContext */
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* Wraps a method with Sentry tracing.
|
|
10
|
+
* Wraps a method with Sentry error tracking and optional tracing.
|
|
11
|
+
* Supports starting new traces and linking to previous invocations via Durable Object storage.
|
|
10
12
|
*
|
|
11
13
|
* @param wrapperOptions - The options for the wrapper.
|
|
12
14
|
* @param handler - The method to wrap.
|
|
@@ -20,128 +22,171 @@ function wrapMethodWithSentry(
|
|
|
20
22
|
callback,
|
|
21
23
|
noMark,
|
|
22
24
|
) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (!wrapperOptions.spanName) {
|
|
58
|
-
try {
|
|
59
|
-
if (callback) {
|
|
60
|
-
callback(...args);
|
|
25
|
+
return ensureInstrumented(
|
|
26
|
+
handler,
|
|
27
|
+
original =>
|
|
28
|
+
new Proxy(original, {
|
|
29
|
+
apply(target, thisArg, args) {
|
|
30
|
+
const { startNewTrace: startNewTrace$1 } = wrapperOptions;
|
|
31
|
+
|
|
32
|
+
// For startNewTrace, always use withIsolationScope to ensure a fresh scope
|
|
33
|
+
// Otherwise, use existing client's scope or isolation scope
|
|
34
|
+
const currentClient = getClient();
|
|
35
|
+
const sentryWithScope = startNewTrace$1 ? withIsolationScope : currentClient ? withScope : withIsolationScope;
|
|
36
|
+
|
|
37
|
+
const wrappedFunction = (scope) => {
|
|
38
|
+
// In certain situations, the passed context can become undefined.
|
|
39
|
+
// For example, for Astro while prerendering pages at build time.
|
|
40
|
+
// see: https://github.com/getsentry/sentry-javascript/issues/13217
|
|
41
|
+
const context = wrapperOptions.context;
|
|
42
|
+
|
|
43
|
+
const waitUntil = context?.waitUntil?.bind?.(context);
|
|
44
|
+
const storage = context && 'originalStorage' in context ? context.originalStorage : undefined;
|
|
45
|
+
|
|
46
|
+
let scopeClient = scope.getClient();
|
|
47
|
+
// Check if client exists AND is still usable (transport not disposed)
|
|
48
|
+
// This handles the case where a previous handler disposed the client
|
|
49
|
+
// but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)
|
|
50
|
+
// For startNewTrace, always create a fresh client
|
|
51
|
+
if (startNewTrace$1 || !scopeClient?.getTransport()) {
|
|
52
|
+
const client = init({
|
|
53
|
+
...wrapperOptions.options,
|
|
54
|
+
ctx: context ,
|
|
55
|
+
});
|
|
56
|
+
scope.setClient(client);
|
|
57
|
+
scopeClient = client;
|
|
61
58
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
59
|
+
|
|
60
|
+
const clientToDispose = scopeClient;
|
|
61
|
+
const methodName = wrapperOptions.spanName || 'unknown';
|
|
62
|
+
|
|
63
|
+
const teardown = async () => {
|
|
64
|
+
if (startNewTrace$1 && storage) {
|
|
65
|
+
await storeSpanContext(storage, methodName);
|
|
66
|
+
}
|
|
67
|
+
await flushAndDispose(clientToDispose);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (!wrapperOptions.spanName) {
|
|
71
|
+
try {
|
|
72
|
+
if (callback) {
|
|
73
|
+
callback(...args);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const result = Reflect.apply(target, thisArg, args);
|
|
77
|
+
|
|
78
|
+
if (isThenable(result)) {
|
|
79
|
+
return result.then(
|
|
80
|
+
(res) => {
|
|
81
|
+
waitUntil?.(teardown());
|
|
82
|
+
return res;
|
|
75
83
|
},
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
84
|
+
(e) => {
|
|
85
|
+
captureException(e, {
|
|
86
|
+
mechanism: {
|
|
87
|
+
type: 'auto.faas.cloudflare.durable_object',
|
|
88
|
+
handled: false,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
waitUntil?.(teardown());
|
|
92
|
+
throw e;
|
|
93
|
+
},
|
|
94
|
+
);
|
|
95
|
+
} else {
|
|
96
|
+
waitUntil?.(teardown());
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
} catch (e) {
|
|
100
|
+
captureException(e, {
|
|
101
|
+
mechanism: {
|
|
102
|
+
type: 'auto.faas.cloudflare.durable_object',
|
|
103
|
+
handled: false,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
waitUntil?.(teardown());
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
101
109
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
(
|
|
110
|
+
|
|
111
|
+
const attributes = wrapperOptions.spanOp
|
|
112
|
+
? {
|
|
113
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
|
|
114
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',
|
|
115
|
+
}
|
|
116
|
+
: {};
|
|
117
|
+
|
|
118
|
+
const executeSpan = () => {
|
|
119
|
+
return startSpan({ name: methodName, attributes }, span => {
|
|
120
|
+
// When linking to previous trace, fetch the stored context and add links asynchronously
|
|
121
|
+
// This avoids blocking the response while fetching from storage
|
|
122
|
+
if (startNewTrace$1 && storage) {
|
|
123
|
+
waitUntil?.(
|
|
124
|
+
getStoredSpanContext(storage, methodName).then(storedContext => {
|
|
125
|
+
if (storedContext) {
|
|
126
|
+
span.addLinks(buildSpanLinks(storedContext));
|
|
127
|
+
// TODO: Remove this once EAP can store span links. We currently only set this attribute so that we
|
|
128
|
+
// can obtain the previous trace information from the EAP store. Long-term, EAP will handle
|
|
129
|
+
// span links and then we should remove this again. Also throwing in a TODO(v11), to remind us
|
|
130
|
+
// to check this at v11 time :)
|
|
131
|
+
const sampledFlag = storedContext.sampled ? '1' : '0';
|
|
132
|
+
span.setAttribute(
|
|
133
|
+
'sentry.previous_trace',
|
|
134
|
+
`${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
const result = Reflect.apply(target, thisArg, args);
|
|
143
|
+
|
|
144
|
+
if (isThenable(result)) {
|
|
145
|
+
return result.then(
|
|
146
|
+
(res) => {
|
|
147
|
+
waitUntil?.(teardown());
|
|
148
|
+
return res;
|
|
149
|
+
},
|
|
150
|
+
(e) => {
|
|
151
|
+
captureException(e, {
|
|
152
|
+
mechanism: {
|
|
153
|
+
type: 'auto.faas.cloudflare.durable_object',
|
|
154
|
+
handled: false,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
waitUntil?.(teardown());
|
|
158
|
+
throw e;
|
|
159
|
+
},
|
|
160
|
+
);
|
|
161
|
+
} else {
|
|
162
|
+
waitUntil?.(teardown());
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
} catch (e) {
|
|
115
166
|
captureException(e, {
|
|
116
167
|
mechanism: {
|
|
117
168
|
type: 'auto.faas.cloudflare.durable_object',
|
|
118
169
|
handled: false,
|
|
119
170
|
},
|
|
120
171
|
});
|
|
121
|
-
waitUntil?.(
|
|
172
|
+
waitUntil?.(teardown());
|
|
122
173
|
throw e;
|
|
123
|
-
}
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
if (startNewTrace$1) {
|
|
179
|
+
return startNewTrace(() => executeSpan());
|
|
128
180
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
return sentryWithScope(wrappedFunction);
|
|
143
|
-
},
|
|
144
|
-
});
|
|
181
|
+
|
|
182
|
+
return executeSpan();
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return sentryWithScope(wrappedFunction);
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
noMark,
|
|
189
|
+
);
|
|
145
190
|
}
|
|
146
191
|
|
|
147
192
|
export { wrapMethodWithSentry };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport {\n captureException,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { init } from './sdk';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | DurableObjectState;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry tracing.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n if (isInstrumented(handler)) {\n return handler;\n }\n\n if (!noMark) {\n markAsInstrumented(handler);\n }\n\n return new Proxy(handler, {\n apply(target, thisArg, args: Parameters<T>) {\n const currentClient = getClient();\n // if a client is already set, use withScope, otherwise use withIsolationScope\n const sentryWithScope = currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context = wrapperOptions.context as InstrumentedDurableObjectState | undefined;\n\n const waitUntil = context?.waitUntil?.bind?.(context);\n\n let currentClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n if (!currentClient?.getTransport()) {\n const client = init({ ...wrapperOptions.options, ctx: context as unknown as ExecutionContext | undefined });\n scope.setClient(client);\n currentClient = client;\n }\n\n const clientToDispose = currentClient;\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(flushAndDispose(clientToDispose));\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(flushAndDispose(clientToDispose));\n throw e;\n },\n );\n } else {\n waitUntil?.(flushAndDispose(clientToDispose));\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(flushAndDispose(clientToDispose));\n throw e;\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',\n }\n : {};\n\n return startSpan({ name: wrapperOptions.spanName, attributes }, () => {\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(flushAndDispose(clientToDispose));\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(flushAndDispose(clientToDispose));\n throw e;\n },\n );\n } else {\n waitUntil?.(flushAndDispose(clientToDispose));\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(flushAndDispose(clientToDispose));\n throw e;\n }\n });\n };\n\n return sentryWithScope(wrappedFunction);\n },\n });\n}\n"],"names":[],"mappings":";;;;;AAiBA;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB;AACpC,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAK;AACL,EAAE,IAAI,cAAc,CAAC,OAAO,CAAC,EAAE;AAC/B,IAAI,OAAO,OAAO;AAClB,EAAE;;AAEF,EAAE,IAAI,CAAC,MAAM,EAAE;AACf,IAAI,kBAAkB,CAAC,OAAO,CAAC;AAC/B,EAAE;;AAEF,EAAE,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;AAC5B,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAiB;AAChD,MAAM,MAAM,aAAA,GAAgB,SAAS,EAAE;AACvC;AACA,MAAM,MAAM,eAAA,GAAkB,gBAAgB,SAAA,GAAY,kBAAkB;;AAE5E,MAAM,MAAM,eAAA,GAAkB,CAAC,KAAK,KAAqB;AACzD;AACA;AACA;AACA,QAAQ,MAAM,OAAA,GAAU,cAAc,CAAC,OAAA;;AAEvC,QAAQ,MAAM,SAAA,GAAY,OAAO,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC;;AAE7D,QAAQ,IAAI,aAAA,GAAgB,KAAK,CAAC,SAAS,EAAE;AAC7C;AACA;AACA;AACA,QAAQ,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE;AAC5C,UAAU,MAAM,MAAA,GAAS,IAAI,CAAC,EAAE,GAAG,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,OAAA,GAAoD,CAAC;AACrH,UAAU,KAAK,C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gBAAgB,IAAI,EAAE,qCAAqC;AAC3D,gBAAgB,OAAO,EAAE,KAAK;AAC9B,eAAe;AACf,aAAa,CAAC;AACd,YAAY,SAAS,GAAG,eAAe,CAAC,eAAe,CAAC,CAAC;AACzD,YAAY,MAAM,CAAC;AACnB,UAAU;AACV,QAAQ,CAAC,CAAC;AACV,MAAM,CAAC;;AAEP,MAAM,OAAO,eAAe,CAAC,eAAe,CAAC;AAC7C,IAAI,CAAC;AACL,GAAG,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport {\n captureException,\n getClient,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport { flushAndDispose } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\ninterface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\ntype MethodWrapperOptions = {\n spanName?: string;\n spanOp?: string;\n options: CloudflareOptions;\n context: ExecutionContext | InstrumentedDurableObjectState;\n /**\n * If true, starts a fresh trace instead of inheriting from a parent trace.\n * Useful for scheduled/independent invocations like alarms.\n *\n * If true, it also stores the current span context and links to the previous invocation's span.\n * Uses Durable Object storage to persist the link. The link is set asynchronously via `span.addLinks()`\n * in a `waitUntil` to avoid blocking.\n *\n * @default false\n */\n startNewTrace?: boolean;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type UncheckedMethod = (...args: any[]) => any;\ntype OriginalMethod = UncheckedMethod;\n\n/**\n * Wraps a method with Sentry error tracking and optional tracing.\n * Supports starting new traces and linking to previous invocations via Durable Object storage.\n *\n * @param wrapperOptions - The options for the wrapper.\n * @param handler - The method to wrap.\n * @param callback - The callback to call.\n * @param noMark - Whether to mark the method as instrumented.\n * @returns The wrapped method.\n */\nexport function wrapMethodWithSentry<T extends OriginalMethod>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n noMark?: true,\n): T {\n return ensureInstrumented(\n handler,\n original =>\n new Proxy(original, {\n apply(target, thisArg, args: Parameters<T>) {\n const { startNewTrace } = wrapperOptions;\n\n // For startNewTrace, always use withIsolationScope to ensure a fresh scope\n // Otherwise, use existing client's scope or isolation scope\n const currentClient = getClient();\n const sentryWithScope = startNewTrace ? withIsolationScope : currentClient ? withScope : withIsolationScope;\n\n const wrappedFunction = (scope: Scope): unknown | Promise<unknown> => {\n // In certain situations, the passed context can become undefined.\n // For example, for Astro while prerendering pages at build time.\n // see: https://github.com/getsentry/sentry-javascript/issues/13217\n const context: typeof wrapperOptions.context | undefined = wrapperOptions.context;\n\n const waitUntil = context?.waitUntil?.bind?.(context);\n const storage = context && 'originalStorage' in context ? context.originalStorage : undefined;\n\n let scopeClient = scope.getClient();\n // Check if client exists AND is still usable (transport not disposed)\n // This handles the case where a previous handler disposed the client\n // but the scope still holds a reference to it (e.g., alarm handlers in Durable Objects)\n // For startNewTrace, always create a fresh client\n if (startNewTrace || !scopeClient?.getTransport()) {\n const client = init({\n ...wrapperOptions.options,\n ctx: context as unknown as ExecutionContext | undefined,\n });\n scope.setClient(client);\n scopeClient = client;\n }\n\n const clientToDispose = scopeClient;\n const methodName = wrapperOptions.spanName || 'unknown';\n\n const teardown = async (): Promise<void> => {\n if (startNewTrace && storage) {\n await storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n },\n );\n } else {\n waitUntil?.(teardown());\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare.durable_object',\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n // When linking to previous trace, fetch the stored context and add links asynchronously\n // This avoids blocking the response while fetching from storage\n if (startNewTrace && storage) {\n waitUntil?.(\n getStoredSpanContext(storage, methodName).then(storedContext => {\n if (storedContext) {\n span.addLinks(buildSpanLinks(storedContext));\n // TODO: Remove this once EAP can store span links. We currently only set this attribute so that we\n // can obtain the previous trace information from the EAP store. Long-term, EAP will handle\n // span links and then we should remove this again. Also throwing in a TODO(v11), to remind us\n // to check this at v11 time :)\n const sampledFlag = storedContext.sampled ? '1' : '0';\n span.setAttribute(\n 'sentry.previous_trace',\n `${storedContext.traceId}-${storedContext.spanId}-${sampledFlag}`,\n );\n }\n }),\n );\n }\n\n try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(\n (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n },\n (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n },\n );\n } else {\n waitUntil?.(teardown());\n return result;\n }\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object',\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\n }\n });\n };\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return sentryWithScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;AAmBA;;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,oBAAoB;AACpC,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAE,MAAM;AACR,EAAK;AACL,EAAE,OAAO,kBAAkB;AAC3B,IAAI,OAAO;AACX,IAAI,QAAA;AACJ,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;AAC1B,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAiB;AACpD,UAAU,MAAM,iBAAEA,eAAA,EAAc,GAAI,cAAc;;AAElD;AACA;AACA,UAAU,MAAM,aAAA,GAAgB,SAAS,EAAE;AAC3C,UAAU,MAAM,eAAA,GAAkBA,eAAA,GAAgB,kBAAA,GAAqB,aAAA,GAAgB,SAAA,GAAY,kBAAkB;;AAErH,UAAU,MAAM,eAAA,GAAkB,CAAC,KAAK,KAAwC;AAChF;AACA;AACA;AACA,YAAY,MAAM,OAAO,GAA8C,cAAc,CAAC,OAAO;;AAE7F,YAAY,MAAM,SAAA,GAAY,OAAO,EAAE,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC;AACjE,YAAY,MAAM,OAAA,GAAU,OAAA,IAAW,iBAAA,IAAqB,OAAA,GAAU,OAAO,CAAC,eAAA,GAAkB,SAAS;;AAEzG,YAAY,IAAI,WAAA,GAAc,KAAK,CAAC,SAAS,EAAE;AAC/C;AACA;AACA;AACA;AACA,YAAY,IAAIA,eAAA,IAAiB,CAAC,WAAW,EAAE,YAAY,EAAE,EAAE;AAC/D,cAAc,MAAM,MAAA,GAAS,IAAI,CAAC;AAClC,gBAAgB,GAAG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YAAA;;AAEA,YAAA,OAAA,WAAA,EAAA;AACA,UAAA,CAAA;;AAEA,UAAA,OAAA,eAAA,CAAA,eAAA,CAAA;AACA,QAAA,CAAA;AACA,OAAA,CAAA;AACA,IAAA,MAAA;AACA,GAAA;AACA;;;;"}
|
package/build/types/client.d.ts
CHANGED
|
@@ -65,26 +65,55 @@ interface BaseCloudflareOptions {
|
|
|
65
65
|
*/
|
|
66
66
|
skipOpenTelemetrySetup?: boolean;
|
|
67
67
|
/**
|
|
68
|
-
* Enable
|
|
68
|
+
* Enable trace propagation for RPC calls between Workers, Durable Objects, and Service Bindings.
|
|
69
69
|
*
|
|
70
|
-
* When
|
|
71
|
-
*
|
|
70
|
+
* When enabled, trace context (sentry-trace + baggage) is propagated across:
|
|
71
|
+
* - `stub.fetch()` calls to Durable Objects (via HTTP headers)
|
|
72
|
+
* - Service binding `fetch()` calls (via HTTP headers)
|
|
73
|
+
* - RPC method calls to Durable Objects (via trailing argument)
|
|
72
74
|
*
|
|
73
|
-
* When
|
|
75
|
+
* When enabled on the **receiver side** (DurableObject), the SDK will also:
|
|
76
|
+
* - Extract and continue traces from incoming RPC calls
|
|
77
|
+
* - Create spans for each RPC method invocation
|
|
78
|
+
* - Capture errors thrown by RPC methods
|
|
74
79
|
*
|
|
75
|
-
* This
|
|
76
|
-
* Only enable this if you need automatic instrumentation of prototype methods.
|
|
80
|
+
* **Important:** This option should be enabled on **both sides** for full trace propagation.
|
|
77
81
|
*
|
|
78
82
|
* @default false
|
|
79
83
|
* @example
|
|
80
84
|
* ```ts
|
|
81
|
-
* //
|
|
82
|
-
*
|
|
85
|
+
* // Worker side (caller)
|
|
86
|
+
* export default Sentry.withSentry(
|
|
87
|
+
* (env) => ({
|
|
88
|
+
* dsn: env.SENTRY_DSN,
|
|
89
|
+
* enableRpcTracePropagation: true,
|
|
90
|
+
* }),
|
|
91
|
+
* handler,
|
|
92
|
+
* );
|
|
83
93
|
*
|
|
84
|
-
* //
|
|
85
|
-
*
|
|
94
|
+
* // Durable Object side (receiver)
|
|
95
|
+
* export const MyDO = Sentry.instrumentDurableObjectWithSentry(
|
|
96
|
+
* (env) => ({
|
|
97
|
+
* dsn: env.SENTRY_DSN,
|
|
98
|
+
* enableRpcTracePropagation: true,
|
|
99
|
+
* }),
|
|
100
|
+
* MyDOBase,
|
|
101
|
+
* );
|
|
86
102
|
* ```
|
|
87
103
|
*/
|
|
104
|
+
enableRpcTracePropagation?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* @deprecated Use `enableRpcTracePropagation` instead. This option will be removed in a future major version.
|
|
107
|
+
*
|
|
108
|
+
* Enable instrumentation of prototype methods for DurableObjects.
|
|
109
|
+
*
|
|
110
|
+
* When `true`, the SDK will wrap all methods on the DurableObject prototype chain
|
|
111
|
+
* to automatically create spans and capture errors for RPC method calls.
|
|
112
|
+
*
|
|
113
|
+
* When an array of strings is provided, only the specified method names will be instrumented.
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
88
117
|
instrumentPrototypeMethods?: boolean | string[];
|
|
89
118
|
}
|
|
90
119
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAA8B,MAAM,cAAc,CAAC;AACvF,OAAO,EAA2B,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA0C;IACrE,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,sBAAsB,CAA8B;IAC5D,OAAO,CAAC,sBAAsB,CAA6B;IAE3D,OAAO,CAAC,qBA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qBAAqB;IAC7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;;;;;;;OAWG;IACH,0BAA0B,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;CACjD;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,0BAA0B,CAAC,EAAE,qBAAqB;IACnG,GAAG,CAAC,EAAE,gBAAgB,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,uBAAwB,SAAQ,aAAa,CAAC,0BAA0B,CAAC,EAAE,qBAAqB;IAC/G,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;CAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"durableobject.d.ts","sourceRoot":"","sources":["../../src/durableobject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"durableobject.d.ts","sourceRoot":"","sources":["../../src/durableobject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAUlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,iCAAiC,CAC/C,CAAC,EACD,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAC1B,CAAC,SAAS,KAAK,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,EACtD,eAAe,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,iBAAiB,EAAE,kBAAkB,EAAE,CAAC,GAAG,CAAC,CAiH1E"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { Breadcrumb, BreadcrumbHint, PolymorphicRequest, RequestEventData, SdkInfo, Event, EventHint, ErrorEvent, Exception, FeatureFlagsIntegration, Session, SeverityLevel, Span, StackFrame, Stacktrace, Thread, User, Metric, ExclusiveEventHintOrCaptureContext, CaptureContext, } from '@sentry/core';
|
|
2
2
|
export type { CloudflareOptions } from './client';
|
|
3
|
-
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, isEnabled, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, startNewTrace, suppressTracing, withActiveSpan, getSpanDescendants, continueTrace, functionToStringIntegration, inboundFiltersIntegration, instrumentOpenAiClient, instrumentGoogleGenAIClient, instrumentAnthropicAiClient, eventFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, supabaseIntegration, instrumentSupabaseClient, instrumentPostgresJsSql, zodErrorsIntegration, consoleIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, updateSpanName, wrapMcpServerWithSentry, consoleLoggingIntegration, createConsolaReporter, createLangChainCallbackHandler, featureFlagsIntegration, growthbookIntegration, logger, metrics, instrumentLangGraph, } from '@sentry/core';
|
|
3
|
+
export { addEventProcessor, addBreadcrumb, addIntegration, captureException, captureEvent, captureMessage, captureFeedback, close, createTransport, lastEventId, flush, getClient, isInitialized, isEnabled, getCurrentScope, getGlobalScope, getIsolationScope, setCurrentClient, Scope, SDK_VERSION, setContext, setExtra, setExtras, setTag, setTags, setUser, setConversationId, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, startNewTrace, suppressTracing, withActiveSpan, getSpanDescendants, continueTrace, functionToStringIntegration, inboundFiltersIntegration, instrumentOpenAiClient, instrumentGoogleGenAIClient, instrumentAnthropicAiClient, eventFiltersIntegration, linkedErrorsIntegration, requestDataIntegration, extraErrorDataIntegration, dedupeIntegration, rewriteFramesIntegration, captureConsoleIntegration, moduleMetadataIntegration, supabaseIntegration, instrumentSupabaseClient, instrumentPostgresJsSql, zodErrorsIntegration, consoleIntegration, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, trpcMiddleware, spanToJSON, spanToTraceHeader, spanToBaggageHeader, updateSpanName, wrapMcpServerWithSentry, consoleLoggingIntegration, createConsolaReporter, createLangChainCallbackHandler, instrumentLangChainEmbeddings, featureFlagsIntegration, growthbookIntegration, logger, metrics, withStreamedSpan, spanStreamingIntegration, instrumentLangGraph, } from '@sentry/core';
|
|
4
4
|
export { withSentry } from './withSentry';
|
|
5
5
|
export { instrumentDurableObjectWithSentry } from './durableobject';
|
|
6
6
|
export { sentryPagesPlugin } from './pages-plugin';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,uBAAuB,EACvB,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,UAAU,EACV,MAAM,EACN,IAAI,EACJ,MAAM,EACN,kCAAkC,EAClC,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,KAAK,EACL,eAAe,EACf,WAAW,EACX,KAAK,EACL,SAAS,EACT,aAAa,EACb,SAAS,EACT,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,2BAA2B,EAE3B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,yBAAyB,EACzB,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,qCAAqC,EACrC,cAAc,EACd,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iB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,MAAM,CAAC;AAE9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,wCAAwC,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mark an object as instrumented.
|
|
2
|
+
* Mark an object as instrumented, storing the instrumented version.
|
|
3
|
+
* @param original The original uninstrumented object
|
|
4
|
+
* @param instrumented The instrumented version (defaults to original if not provided)
|
|
3
5
|
*/
|
|
4
|
-
export declare function markAsInstrumented<T>(
|
|
6
|
+
export declare function markAsInstrumented<T>(original: T, instrumented?: T): void;
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Get the instrumented version of an object, if available.
|
|
9
|
+
* Returns the instrumented version if the object was previously instrumented,
|
|
10
|
+
* or undefined if not found.
|
|
7
11
|
*/
|
|
8
|
-
export declare function
|
|
12
|
+
export declare function getInstrumented<T>(obj: T): T | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the already-instrumented version of `original` if one exists,
|
|
15
|
+
* otherwise calls `instrumentFn` to create it, marks the mapping, and returns it.
|
|
16
|
+
*
|
|
17
|
+
* @param noMark - If true, skips storing the original→instrumented mapping.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ensureInstrumented<T>(original: T, instrumentFn: (original: T) => T, noMark?: boolean): T;
|
|
9
20
|
//# sourceMappingURL=instrument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../../src/instrument.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../../src/instrument.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,IAAI,CAczE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS,CAUxD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,CAAC,CAcxG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DurableObjectNamespace } from '@cloudflare/workers-types';
|
|
2
|
+
/**
|
|
3
|
+
* Instruments a DurableObjectNamespace binding to create spans for DO interactions.
|
|
4
|
+
*
|
|
5
|
+
* Wraps:
|
|
6
|
+
* - `namespace.get(id)` / `namespace.getByName(name)` with a span + instruments returned stub
|
|
7
|
+
* - `namespace.idFromName(name)` / `namespace.idFromString(id)` / `namespace.newUniqueId()` with breadcrumbs
|
|
8
|
+
*
|
|
9
|
+
* @param namespace - The DurableObjectNamespace to instrument
|
|
10
|
+
*/
|
|
11
|
+
export declare function instrumentDurableObjectNamespace(namespace: DurableObjectNamespace): DurableObjectNamespace;
|
|
12
|
+
//# sourceMappingURL=instrumentDurableObjectNamespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentDurableObjectNamespace.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentDurableObjectNamespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAqB,MAAM,2BAA2B,CAAC;AAG3F;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,sBAAsB,GAAG,sBAAsB,CAoB1G"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import type { DurableObjectStorage } from '@cloudflare/workers-types';
|
|
2
|
+
type WaitUntil = (promise: Promise<unknown>) => void;
|
|
2
3
|
/**
|
|
3
4
|
* Instruments DurableObjectStorage methods with Sentry spans.
|
|
4
5
|
*
|
|
5
6
|
* Wraps the following async methods:
|
|
6
7
|
* - get, put, delete, list (KV API)
|
|
8
|
+
* - setAlarm, getAlarm, deleteAlarm (Alarm API)
|
|
9
|
+
*
|
|
10
|
+
* When setAlarm is called, it also stores the current span context so that when
|
|
11
|
+
* the alarm fires later, it can link back to the trace that called setAlarm.
|
|
7
12
|
*
|
|
8
13
|
* @param storage - The DurableObjectStorage instance to instrument
|
|
14
|
+
* @param waitUntil - Optional waitUntil function to defer span context storage
|
|
9
15
|
* @returns An instrumented DurableObjectStorage instance
|
|
10
16
|
*/
|
|
11
|
-
export declare function instrumentDurableObjectStorage(storage: DurableObjectStorage): DurableObjectStorage;
|
|
17
|
+
export declare function instrumentDurableObjectStorage(storage: DurableObjectStorage, waitUntil?: WaitUntil): DurableObjectStorage;
|
|
18
|
+
export {};
|
|
12
19
|
//# sourceMappingURL=instrumentDurableObjectStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentDurableObjectStorage.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentDurableObjectStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentDurableObjectStorage.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentDurableObjectStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAQtE,KAAK,SAAS,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,oBAAoB,EAC7B,SAAS,CAAC,EAAE,SAAS,GACpB,oBAAoB,CAgEtB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { env as cloudflareEnv, WorkerEntrypoint } from 'cloudflare:workers';
|
|
2
|
+
import type { CloudflareOptions } from '../client';
|
|
3
|
+
export type WorkerEntrypointConstructor<Env = typeof cloudflareEnv, Props = {}> = new (ctx: ExecutionContext, env: typeof cloudflareEnv) => InstanceType<typeof WorkerEntrypoint<Env, Props>>;
|
|
4
|
+
/**
|
|
5
|
+
* Instruments a WorkerEntrypoint class to capture errors and performance data.
|
|
6
|
+
*
|
|
7
|
+
* Instruments the following methods (same as `withSentry` for ExportedHandler):
|
|
8
|
+
* - fetch (HTTP requests)
|
|
9
|
+
* - scheduled (cron triggers)
|
|
10
|
+
* - queue (queue consumers)
|
|
11
|
+
* - email (email handlers)
|
|
12
|
+
* - tail (tail workers)
|
|
13
|
+
*
|
|
14
|
+
* as well as any other public RPC methods on the WorkerEntrypoint instance.
|
|
15
|
+
*
|
|
16
|
+
* @param optionsCallback Function that returns the options for the SDK initialization.
|
|
17
|
+
* @param WorkerEntrypointClass The WorkerEntrypoint class to instrument.
|
|
18
|
+
* @returns The instrumented WorkerEntrypoint class.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* class MyWorkerBase extends WorkerEntrypoint<Env> {
|
|
23
|
+
* async fetch(request: Request): Promise<Response> {
|
|
24
|
+
* return new Response('Hello World!');
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* async myRpcMethod(arg: string): Promise<string> {
|
|
28
|
+
* return `Hello ${arg}!`;
|
|
29
|
+
* }
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* export default instrumentWorkerEntrypoint(
|
|
33
|
+
* env => ({
|
|
34
|
+
* dsn: env.SENTRY_DSN,
|
|
35
|
+
* tracesSampleRate: 1.0,
|
|
36
|
+
* }),
|
|
37
|
+
* MyWorkerBase,
|
|
38
|
+
* );
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function instrumentWorkerEntrypoint<T extends WorkerEntrypointConstructor>(optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined, WorkerEntrypointClass: T): T;
|
|
42
|
+
//# sourceMappingURL=instrumentWorkerEntrypoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentWorkerEntrypoint.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentWorkerEntrypoint.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,IAAI,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAQnD,MAAM,MAAM,2BAA2B,CAAC,GAAG,GAAG,OAAO,aAAa,EAAE,KAAK,GAAG,EAAE,IAAI,KAChF,GAAG,EAAE,gBAAgB,EACrB,GAAG,EAAE,OAAO,aAAa,KACtB,YAAY,CAAC,OAAO,gBAAgB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,SAAS,2BAA2B,EAC9E,eAAe,EAAE,CAAC,GAAG,EAAE,OAAO,aAAa,KAAK,iBAAiB,GAAG,SAAS,EAC7E,qBAAqB,EAAE,CAAC,GACvB,CAAC,CA+CH"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ExportedHandler } from '@cloudflare/workers-types';
|
|
2
|
+
import type { env as cloudflareEnv } from 'cloudflare:workers';
|
|
2
3
|
import type { CloudflareOptions } from '../../client';
|
|
3
4
|
/**
|
|
4
5
|
* Instruments an email handler for ExportedHandler (env/ctx come from args).
|
|
5
6
|
*/
|
|
6
|
-
export declare function instrumentExportedHandlerEmail<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env:
|
|
7
|
+
export declare function instrumentExportedHandlerEmail<T extends ExportedHandler<any, any, any>>(handler: T, optionsCallback: (env: typeof cloudflareEnv) => CloudflareOptions | undefined): void;
|
|
7
8
|
//# sourceMappingURL=instrumentEmail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentEmail.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentEmail.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/worker/instrumentEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAQ/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAkDtD;;GAEG;AAEH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACrF,OAAO,EAAE,CAAC,EACV,eAAe,EAAE,CAAC,GAAG,EAAE,OAAO,aAAa,KAAK,iBAAiB,GAAG,SAAS,GAC5E,IAAI,CAoBN"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CloudflareOptions } from '../../client';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the Cloudflare `env` object in a Proxy that detects binding types
|
|
4
|
+
* on property access and returns instrumented versions.
|
|
5
|
+
*
|
|
6
|
+
* Currently detects:
|
|
7
|
+
* - DurableObjectNamespace (via `idFromName` duck-typing)
|
|
8
|
+
* - Service bindings / JSRPC proxies (wraps `fetch` for trace propagation)
|
|
9
|
+
*
|
|
10
|
+
* Extensible for future binding types (KV, D1, Queue, etc.).
|
|
11
|
+
*
|
|
12
|
+
* @param env - The Cloudflare env object to instrument
|
|
13
|
+
* @param options - Optional CloudflareOptions to control RPC trace propagation
|
|
14
|
+
*/
|
|
15
|
+
export declare function instrumentEnv<Env extends Record<string, unknown>>(env: Env, options?: CloudflareOptions): Env;
|
|
16
|
+
//# sourceMappingURL=instrumentEnv.d.ts.map
|