@sentry/cloudflare 9.14.0 → 9.16.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 -1
- package/build/cjs/async.js.map +1 -1
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/d1.js.map +1 -1
- package/build/cjs/durableobject.js +213 -0
- package/build/cjs/durableobject.js.map +1 -0
- package/build/cjs/handler.js +56 -66
- package/build/cjs/handler.js.map +1 -1
- package/build/cjs/index.js +6 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrument.js +27 -0
- package/build/cjs/instrument.js.map +1 -0
- package/build/cjs/integrations/fetch.js.map +1 -1
- package/build/cjs/logs/exports.js +213 -0
- package/build/cjs/logs/exports.js.map +1 -0
- package/build/cjs/options.js +23 -0
- package/build/cjs/options.js.map +1 -0
- package/build/cjs/request.js +12 -0
- package/build/cjs/request.js.map +1 -1
- package/build/cjs/scope-utils.js.map +1 -1
- package/build/cjs/sdk.js +1 -0
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/transport.js.map +1 -1
- package/build/cjs/vendor/stacktrace.js +0 -4
- package/build/cjs/vendor/stacktrace.js.map +1 -1
- package/build/esm/async.js +4 -1
- package/build/esm/async.js.map +1 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/d1.js.map +1 -1
- package/build/esm/durableobject.js +211 -0
- package/build/esm/durableobject.js.map +1 -0
- package/build/esm/handler.js +56 -66
- package/build/esm/handler.js.map +1 -1
- package/build/esm/index.js +4 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/instrument.js +24 -0
- package/build/esm/instrument.js.map +1 -0
- package/build/esm/integrations/fetch.js.map +1 -1
- package/build/esm/logs/exports.js +206 -0
- package/build/esm/logs/exports.js.map +1 -0
- package/build/esm/options.js +21 -0
- package/build/esm/options.js.map +1 -0
- package/build/esm/package.json +1 -1
- package/build/esm/request.js +13 -1
- package/build/esm/request.js.map +1 -1
- package/build/esm/scope-utils.js.map +1 -1
- package/build/esm/sdk.js +1 -0
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/transport.js.map +1 -1
- package/build/esm/vendor/stacktrace.js +0 -4
- package/build/esm/vendor/stacktrace.js.map +1 -1
- package/build/types/async.d.ts.map +1 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/durableobject.d.ts +38 -0
- package/build/types/durableobject.d.ts.map +1 -0
- package/build/types/handler.d.ts +2 -7
- package/build/types/handler.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrument.d.ts +9 -0
- package/build/types/instrument.d.ts.map +1 -0
- package/build/types/logs/exports.d.ts +169 -0
- package/build/types/logs/exports.d.ts.map +1 -0
- package/build/types/options.d.ts +12 -0
- package/build/types/options.d.ts.map +1 -0
- package/build/types/request.d.ts.map +1 -1
- package/build/types/scope-utils.d.ts.map +1 -1
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/vendor/stacktrace.d.ts.map +1 -1
- package/build/types-ts3.8/durableobject.d.ts +38 -0
- package/build/types-ts3.8/handler.d.ts +2 -7
- package/build/types-ts3.8/index.d.ts +4 -1
- package/build/types-ts3.8/instrument.d.ts +9 -0
- package/build/types-ts3.8/logs/exports.d.ts +169 -0
- package/build/types-ts3.8/options.d.ts +12 -0
- package/package.json +2 -2
package/build/cjs/async.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
|
-
const core = require('@sentry/core');
|
|
4
3
|
const node_async_hooks = require('node:async_hooks');
|
|
4
|
+
const core = require('@sentry/core');
|
|
5
|
+
|
|
6
|
+
// Need to use node: prefix for cloudflare workers compatibility
|
|
7
|
+
// Note: Because we are using node:async_hooks, we need to set `node_compat` in the wrangler.toml
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Sets the async context strategy to use AsyncLocalStorage.
|
package/build/cjs/async.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.js","sources":["../../src/async.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"async.js","sources":["../../src/async.ts"],"sourcesContent":["// Need to use node: prefix for cloudflare workers compatibility\n// Note: Because we are using node:async_hooks, we need to set `node_compat` in the wrangler.toml\nimport { AsyncLocalStorage } from 'node:async_hooks';\nimport type { Scope } from '@sentry/core';\nimport { getDefaultCurrentScope, getDefaultIsolationScope, setAsyncContextStrategy } from '@sentry/core';\n\n/**\n * Sets the async context strategy to use AsyncLocalStorage.\n *\n * AsyncLocalStorage is only available in the cloudflare workers runtime if you set\n * compatibility_flags = [\"nodejs_compat\"] or compatibility_flags = [\"nodejs_als\"]\n *\n * @internal Only exported to be used in higher-level Sentry packages\n * @hidden Only exported to be used in higher-level Sentry packages\n */\nexport function setAsyncLocalStorageAsyncContextStrategy(): void {\n const asyncStorage = new AsyncLocalStorage<{\n scope: Scope;\n isolationScope: Scope;\n }>();\n\n function getScopes(): { scope: Scope; isolationScope: Scope } {\n const scopes = asyncStorage.getStore();\n\n if (scopes) {\n return scopes;\n }\n\n // fallback behavior:\n // if, for whatever reason, we can't find scopes on the context here, we have to fix this somehow\n return {\n scope: getDefaultCurrentScope(),\n isolationScope: getDefaultIsolationScope(),\n };\n }\n\n function withScope<T>(callback: (scope: Scope) => T): T {\n const scope = getScopes().scope.clone();\n const isolationScope = getScopes().isolationScope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withSetScope<T>(scope: Scope, callback: (scope: Scope) => T): T {\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(scope);\n });\n }\n\n function withIsolationScope<T>(callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n const isolationScope = getScopes().isolationScope.clone();\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n function withSetIsolationScope<T>(isolationScope: Scope, callback: (isolationScope: Scope) => T): T {\n const scope = getScopes().scope;\n return asyncStorage.run({ scope, isolationScope }, () => {\n return callback(isolationScope);\n });\n }\n\n setAsyncContextStrategy({\n withScope,\n withSetScope,\n withIsolationScope,\n withSetIsolationScope,\n getCurrentScope: () => getScopes().scope,\n getIsolationScope: () => getScopes().isolationScope,\n });\n}\n"],"names":["AsyncLocalStorage","getDefaultCurrentScope","getDefaultIsolationScope","setAsyncContextStrategy"],"mappings":";;;;;AAAA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wCAAwC,GAAS;AACjE,EAAE,MAAM,YAAA,GAAe,IAAIA;;AAGzB,EAAI;;AAEN,EAAE,SAAS,SAAS,GAA4C;AAChE,IAAI,MAAM,MAAO,GAAE,YAAY,CAAC,QAAQ,EAAE;;AAE1C,IAAI,IAAI,MAAM,EAAE;AAChB,MAAM,OAAO,MAAM;AACnB;;AAEA;AACA;AACA,IAAI,OAAO;AACX,MAAM,KAAK,EAAEC,2BAAsB,EAAE;AACrC,MAAM,cAAc,EAAEC,6BAAwB,EAAE;AAChD,KAAK;AACL;;AAEA,EAAE,SAAS,SAAS,CAAI,QAAQ,EAA0B;AAC1D,IAAI,MAAM,KAAM,GAAE,SAAS,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE;AAC3C,IAAI,MAAM,cAAe,GAAE,SAAS,EAAE,CAAC,cAAc;AACrD,IAAI,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAe,EAAC,EAAE,MAAM;AAC7D,MAAM,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC5B,KAAK,CAAC;AACN;;AAEA,EAAE,SAAS,YAAY,CAAI,KAAK,EAAS,QAAQ,EAA0B;AAC3E,IAAI,MAAM,cAAe,GAAE,SAAS,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE;AAC7D,IAAI,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAe,EAAC,EAAE,MAAM;AAC7D,MAAM,OAAO,QAAQ,CAAC,KAAK,CAAC;AAC5B,KAAK,CAAC;AACN;;AAEA,EAAE,SAAS,kBAAkB,CAAI,QAAQ,EAAmC;AAC5E,IAAI,MAAM,KAAM,GAAE,SAAS,EAAE,CAAC,KAAK;AACnC,IAAI,MAAM,cAAe,GAAE,SAAS,EAAE,CAAC,cAAc,CAAC,KAAK,EAAE;AAC7D,IAAI,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAe,EAAC,EAAE,MAAM;AAC7D,MAAM,OAAO,QAAQ,CAAC,cAAc,CAAC;AACrC,KAAK,CAAC;AACN;;AAEA,EAAE,SAAS,qBAAqB,CAAI,cAAc,EAAS,QAAQ,EAAmC;AACtG,IAAI,MAAM,KAAM,GAAE,SAAS,EAAE,CAAC,KAAK;AACnC,IAAI,OAAO,YAAY,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,cAAe,EAAC,EAAE,MAAM;AAC7D,MAAM,OAAO,QAAQ,CAAC,cAAc,CAAC;AACrC,KAAK,CAAC;AACN;;AAEA,EAAEC,4BAAuB,CAAC;AAC1B,IAAI,SAAS;AACb,IAAI,YAAY;AAChB,IAAI,kBAAkB;AACtB,IAAI,qBAAqB;AACzB,IAAI,eAAe,EAAE,MAAM,SAAS,EAAE,CAAC,KAAK;AAC5C,IAAI,iBAAiB,EAAE,MAAM,SAAS,EAAE,CAAC,cAAc;AACvD,GAAG,CAAC;AACJ;;;;"}
|
package/build/cjs/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../src/client.ts"],"sourcesContent":["import type { ClientOptions, Options, ServerRuntimeClientOptions } from '@sentry/core';\nimport {
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../src/client.ts"],"sourcesContent":["import type { ClientOptions, Options, ServerRuntimeClientOptions } from '@sentry/core';\nimport { applySdkMetadata, ServerRuntimeClient } from '@sentry/core';\nimport type { CloudflareTransportOptions } from './transport';\n\n/**\n * The Sentry Cloudflare SDK Client.\n *\n * @see CloudflareClientOptions for documentation on configuration options.\n * @see ServerRuntimeClient for usage documentation.\n */\nexport class CloudflareClient extends ServerRuntimeClient<CloudflareClientOptions> {\n /**\n * Creates a new Cloudflare SDK instance.\n * @param options Configuration options for this SDK.\n */\n public constructor(options: CloudflareClientOptions) {\n applySdkMetadata(options, 'cloudflare');\n options._metadata = options._metadata || {};\n\n const clientOptions: ServerRuntimeClientOptions = {\n ...options,\n platform: 'javascript',\n // TODO: Grab version information\n runtime: { name: 'cloudflare' },\n // TODO: Add server name\n };\n\n super(clientOptions);\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface BaseCloudflareOptions {}\n\n/**\n * Configuration options for the Sentry Cloudflare SDK\n *\n * @see @sentry/core Options for more information.\n */\nexport interface CloudflareOptions extends Options<CloudflareTransportOptions>, BaseCloudflareOptions {}\n\n/**\n * Configuration options for the Sentry Cloudflare SDK Client class\n *\n * @see CloudflareClient for more information.\n */\nexport interface CloudflareClientOptions extends ClientOptions<CloudflareTransportOptions>, BaseCloudflareOptions {}\n"],"names":["ServerRuntimeClient","applySdkMetadata"],"mappings":";;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,gBAAA,SAAyBA,wBAAmB,CAA0B;AACnF;AACA;AACA;AACA;AACA,GAAS,WAAW,CAAC,OAAO,EAA2B;AACvD,IAAIC,qBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC;AAC3C,IAAI,OAAO,CAAC,SAAU,GAAE,OAAO,CAAC,SAAA,IAAa,EAAE;;AAE/C,IAAI,MAAM,aAAa,GAA+B;AACtD,MAAM,GAAG,OAAO;AAChB,MAAM,QAAQ,EAAE,YAAY;AAC5B;AACA,MAAM,OAAO,EAAE,EAAE,IAAI,EAAE,cAAc;AACrC;AACA,KAAK;;AAEL,IAAI,KAAK,CAAC,aAAa,CAAC;AACxB;AACA;;AAEA;;;;"}
|
package/build/cjs/d1.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d1.js","sources":["../../src/d1.ts"],"sourcesContent":["import type { D1Database, D1PreparedStatement, D1Response } from '@cloudflare/workers-types';\nimport {
|
|
1
|
+
{"version":3,"file":"d1.js","sources":["../../src/d1.ts"],"sourcesContent":["import type { D1Database, D1PreparedStatement, D1Response } from '@cloudflare/workers-types';\nimport type { Span, SpanAttributes, StartSpanOptions } from '@sentry/core';\nimport { addBreadcrumb, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_STATUS_ERROR, startSpan } from '@sentry/core';\n\n// Patching is based on internal Cloudflare D1 API\n// https://github.com/cloudflare/workerd/blob/cd5279e7b305003f1d9c851e73efa9d67e4b68b2/src/cloudflare/internal/d1-api.ts\n\nconst patchedStatement = new WeakSet<D1PreparedStatement>();\n\n/**\n * Patches the query methods of a Cloudflare D1 prepared statement with Sentry.\n */\nfunction instrumentD1PreparedStatementQueries(statement: D1PreparedStatement, query: string): D1PreparedStatement {\n if (patchedStatement.has(statement)) {\n return statement;\n }\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n statement.first = new Proxy(statement.first, {\n apply(target, thisArg, args: Parameters<typeof statement.first>) {\n return startSpan(createStartSpanOptions(query, 'first'), async () => {\n const res = await Reflect.apply(target, thisArg, args);\n createD1Breadcrumb(query, 'first');\n return res;\n });\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n statement.run = new Proxy(statement.run, {\n apply(target, thisArg, args: Parameters<typeof statement.run>) {\n return startSpan(createStartSpanOptions(query, 'run'), async span => {\n const d1Response = await Reflect.apply(target, thisArg, args);\n applyD1ReturnObjectToSpan(span, d1Response);\n createD1Breadcrumb(query, 'run', d1Response);\n return d1Response;\n });\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n statement.all = new Proxy(statement.all, {\n apply(target, thisArg, args: Parameters<typeof statement.all>) {\n return startSpan(createStartSpanOptions(query, 'all'), async span => {\n const d1Result = await Reflect.apply(target, thisArg, args);\n applyD1ReturnObjectToSpan(span, d1Result);\n createD1Breadcrumb(query, 'all', d1Result);\n return d1Result;\n });\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n statement.raw = new Proxy(statement.raw, {\n apply(target, thisArg, args: Parameters<typeof statement.raw>) {\n return startSpan(createStartSpanOptions(query, 'raw'), async () => {\n const res = await Reflect.apply(target, thisArg, args);\n createD1Breadcrumb(query, 'raw');\n return res;\n });\n },\n });\n\n patchedStatement.add(statement);\n\n return statement;\n}\n\n/**\n * Instruments a Cloudflare D1 prepared statement with Sentry.\n *\n * This is meant to be used as a top-level call, under the hood it calls `instrumentD1PreparedStatementQueries`\n * to patch the query methods. The reason for this abstraction is to ensure that the `bind` method is also patched.\n */\nfunction instrumentD1PreparedStatement(statement: D1PreparedStatement, query: string): D1PreparedStatement {\n // statement.bind() returns a new instance of D1PreparedStatement, so we have to patch it as well.\n // eslint-disable-next-line @typescript-eslint/unbound-method\n statement.bind = new Proxy(statement.bind, {\n apply(target, thisArg, args: Parameters<typeof statement.bind>) {\n return instrumentD1PreparedStatementQueries(Reflect.apply(target, thisArg, args), query);\n },\n });\n\n return instrumentD1PreparedStatementQueries(statement, query);\n}\n\n/**\n * Add D1Response meta information to a span.\n *\n * See: https://developers.cloudflare.com/d1/build-with-d1/d1-client-api/#return-object\n */\nfunction applyD1ReturnObjectToSpan(span: Span, d1Result: D1Response): void {\n if (!d1Result.success) {\n span.setStatus({ code: SPAN_STATUS_ERROR });\n }\n\n span.setAttributes(getAttributesFromD1Response(d1Result));\n}\n\nfunction getAttributesFromD1Response(d1Result: D1Response): SpanAttributes {\n return {\n 'cloudflare.d1.duration': d1Result.meta.duration,\n 'cloudflare.d1.rows_read': d1Result.meta.rows_read,\n 'cloudflare.d1.rows_written': d1Result.meta.rows_written,\n };\n}\n\nfunction createD1Breadcrumb(query: string, type: 'first' | 'run' | 'all' | 'raw', d1Result?: D1Response): void {\n addBreadcrumb({\n category: 'query',\n message: query,\n data: {\n ...(d1Result ? getAttributesFromD1Response(d1Result) : {}),\n 'cloudflare.d1.query_type': type,\n },\n });\n}\n\nfunction createStartSpanOptions(query: string, type: 'first' | 'run' | 'all' | 'raw'): StartSpanOptions {\n return {\n op: 'db.query',\n name: query,\n attributes: {\n 'cloudflare.d1.query_type': type,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.db.cloudflare.d1',\n },\n };\n}\n\n/**\n * Instruments Cloudflare D1 bindings with Sentry.\n *\n * Currently, only prepared statements are instrumented. `db.exec` and `db.batch` are not instrumented.\n *\n * @example\n *\n * ```js\n * // env.DB is the D1 DB binding configured in your `wrangler.toml`\n * const db = instrumentD1WithSentry(env.DB);\n * // Now you can use the database as usual\n * await db.prepare('SELECT * FROM table WHERE id = ?').bind(1).run();\n * ```\n */\nexport function instrumentD1WithSentry(db: D1Database): D1Database {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n db.prepare = new Proxy(db.prepare, {\n apply(target, thisArg, args: Parameters<typeof db.prepare>) {\n const [query] = args;\n return instrumentD1PreparedStatement(Reflect.apply(target, thisArg, args), query);\n },\n });\n\n return db;\n}\n"],"names":["startSpan","SPAN_STATUS_ERROR","addBreadcrumb","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN"],"mappings":";;;;AAIA;AACA;;AAEA,MAAM,gBAAiB,GAAE,IAAI,OAAO,EAAuB;;AAE3D;AACA;AACA;AACA,SAAS,oCAAoC,CAAC,SAAS,EAAuB,KAAK,EAA+B;AAClH,EAAE,IAAI,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;AACvC,IAAI,OAAO,SAAS;AACpB;;AAEA;AACA,EAAE,SAAS,CAAC,KAAA,GAAQ,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE;AAC/C,IAAI,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAsC;AACrE,MAAM,OAAOA,cAAS,CAA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AM,MAAM,CAAC,KAAK,CAAA,GAAI,IAAI;AAC1B,MAAM,OAAO,6BAA6B,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC;AACvF,KAAK;AACL,GAAG,CAAC;;AAEJ,EAAE,OAAO,EAAE;AACX;;;;"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
const core = require('@sentry/core');
|
|
4
|
+
const async = require('./async.js');
|
|
5
|
+
const instrument = require('./instrument.js');
|
|
6
|
+
const options = require('./options.js');
|
|
7
|
+
const request = require('./request.js');
|
|
8
|
+
const sdk = require('./sdk.js');
|
|
9
|
+
|
|
10
|
+
/* eslint-disable @typescript-eslint/unbound-method */
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
function wrapMethodWithSentry(
|
|
14
|
+
wrapperOptions,
|
|
15
|
+
handler,
|
|
16
|
+
callback,
|
|
17
|
+
) {
|
|
18
|
+
if (instrument.isInstrumented(handler)) {
|
|
19
|
+
return handler;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
instrument.markAsInstrumented(handler);
|
|
23
|
+
|
|
24
|
+
return new Proxy(handler, {
|
|
25
|
+
apply(target, thisArg, args) {
|
|
26
|
+
const currentClient = core.getClient();
|
|
27
|
+
// if a client is already set, use withScope, otherwise use withIsolationScope
|
|
28
|
+
const sentryWithScope = currentClient ? core.withScope : core.withIsolationScope;
|
|
29
|
+
return sentryWithScope(async scope => {
|
|
30
|
+
// In certain situations, the passed context can become undefined.
|
|
31
|
+
// For example, for Astro while prerendering pages at build time.
|
|
32
|
+
// see: https://github.com/getsentry/sentry-javascript/issues/13217
|
|
33
|
+
const context = wrapperOptions.context ;
|
|
34
|
+
|
|
35
|
+
const currentClient = scope.getClient();
|
|
36
|
+
if (!currentClient) {
|
|
37
|
+
const client = sdk.init(wrapperOptions.options);
|
|
38
|
+
scope.setClient(client);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!wrapperOptions.spanName) {
|
|
42
|
+
try {
|
|
43
|
+
if (callback) {
|
|
44
|
+
callback(...args);
|
|
45
|
+
}
|
|
46
|
+
return await Reflect.apply(target, thisArg, args);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
core.captureException(e, {
|
|
49
|
+
mechanism: {
|
|
50
|
+
type: 'cloudflare_durableobject',
|
|
51
|
+
handled: false,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
throw e;
|
|
55
|
+
} finally {
|
|
56
|
+
context?.waitUntil(core.flush(2000));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const attributes = wrapperOptions.spanOp
|
|
61
|
+
? {
|
|
62
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,
|
|
63
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare_durableobjects',
|
|
64
|
+
}
|
|
65
|
+
: {};
|
|
66
|
+
|
|
67
|
+
// Only create these spans if they have a parent span.
|
|
68
|
+
return core.startSpan({ name: wrapperOptions.spanName, attributes, onlyIfParent: true }, async () => {
|
|
69
|
+
try {
|
|
70
|
+
return await Reflect.apply(target, thisArg, args);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
core.captureException(e, {
|
|
73
|
+
mechanism: {
|
|
74
|
+
type: 'cloudflare_durableobject',
|
|
75
|
+
handled: false,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
throw e;
|
|
79
|
+
} finally {
|
|
80
|
+
context?.waitUntil(core.flush(2000));
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Instruments a Durable Object class to capture errors and performance data.
|
|
90
|
+
*
|
|
91
|
+
* Instruments the following methods:
|
|
92
|
+
* - fetch
|
|
93
|
+
* - alarm
|
|
94
|
+
* - webSocketMessage
|
|
95
|
+
* - webSocketClose
|
|
96
|
+
* - webSocketError
|
|
97
|
+
*
|
|
98
|
+
* as well as any other public RPC methods on the Durable Object instance.
|
|
99
|
+
*
|
|
100
|
+
* @param optionsCallback Function that returns the options for the SDK initialization.
|
|
101
|
+
* @param DurableObjectClass The Durable Object class to instrument.
|
|
102
|
+
* @returns The instrumented Durable Object class.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* class MyDurableObjectBase extends DurableObject {
|
|
107
|
+
* constructor(ctx: DurableObjectState, env: Env) {
|
|
108
|
+
* super(ctx, env);
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* export const MyDurableObject = instrumentDurableObjectWithSentry(
|
|
113
|
+
* env => ({
|
|
114
|
+
* dsn: env.SENTRY_DSN,
|
|
115
|
+
* tracesSampleRate: 1.0,
|
|
116
|
+
* }),
|
|
117
|
+
* MyDurableObjectBase,
|
|
118
|
+
* );
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
function instrumentDurableObjectWithSentry(
|
|
122
|
+
optionsCallback,
|
|
123
|
+
DurableObjectClass,
|
|
124
|
+
) {
|
|
125
|
+
return new Proxy(DurableObjectClass, {
|
|
126
|
+
construct(target, [context, env]) {
|
|
127
|
+
async.setAsyncLocalStorageAsyncContextStrategy();
|
|
128
|
+
|
|
129
|
+
const options$1 = options.getFinalOptions(optionsCallback(env), env);
|
|
130
|
+
|
|
131
|
+
const obj = new target(context, env);
|
|
132
|
+
|
|
133
|
+
// These are the methods that are available on a Durable Object
|
|
134
|
+
// ref: https://developers.cloudflare.com/durable-objects/api/base/
|
|
135
|
+
// obj.alarm
|
|
136
|
+
// obj.fetch
|
|
137
|
+
// obj.webSocketError
|
|
138
|
+
// obj.webSocketClose
|
|
139
|
+
// obj.webSocketMessage
|
|
140
|
+
|
|
141
|
+
// Any other public methods on the Durable Object instance are RPC calls.
|
|
142
|
+
|
|
143
|
+
if (obj.fetch && typeof obj.fetch === 'function' && !instrument.isInstrumented(obj.fetch)) {
|
|
144
|
+
obj.fetch = new Proxy(obj.fetch, {
|
|
145
|
+
apply(target, thisArg, args) {
|
|
146
|
+
return request.wrapRequestHandler({ options: options$1, request: args[0], context }, () =>
|
|
147
|
+
Reflect.apply(target, thisArg, args),
|
|
148
|
+
);
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
instrument.markAsInstrumented(obj.fetch);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (obj.alarm && typeof obj.alarm === 'function') {
|
|
156
|
+
obj.alarm = wrapMethodWithSentry({ options: options$1, context, spanName: 'alarm' }, obj.alarm);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (obj.webSocketMessage && typeof obj.webSocketMessage === 'function') {
|
|
160
|
+
obj.webSocketMessage = wrapMethodWithSentry(
|
|
161
|
+
{ options: options$1, context, spanName: 'webSocketMessage' },
|
|
162
|
+
obj.webSocketMessage,
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (obj.webSocketClose && typeof obj.webSocketClose === 'function') {
|
|
167
|
+
obj.webSocketClose = wrapMethodWithSentry({ options: options$1, context, spanName: 'webSocketClose' }, obj.webSocketClose);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (obj.webSocketError && typeof obj.webSocketError === 'function') {
|
|
171
|
+
obj.webSocketError = wrapMethodWithSentry(
|
|
172
|
+
{ options: options$1, context, spanName: 'webSocketError' },
|
|
173
|
+
obj.webSocketError,
|
|
174
|
+
(_, error) =>
|
|
175
|
+
core.captureException(error, {
|
|
176
|
+
mechanism: {
|
|
177
|
+
type: 'cloudflare_durableobject_websocket',
|
|
178
|
+
handled: false,
|
|
179
|
+
},
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
for (const method of Object.getOwnPropertyNames(obj)) {
|
|
185
|
+
if (
|
|
186
|
+
method === 'fetch' ||
|
|
187
|
+
method === 'alarm' ||
|
|
188
|
+
method === 'webSocketError' ||
|
|
189
|
+
method === 'webSocketClose' ||
|
|
190
|
+
method === 'webSocketMessage'
|
|
191
|
+
) {
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
196
|
+
const value = (obj )[method] ;
|
|
197
|
+
if (typeof value === 'function') {
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
|
199
|
+
(obj )[method] = wrapMethodWithSentry(
|
|
200
|
+
{ options: options$1, context, spanName: method, spanOp: 'rpc' },
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
+
value ,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return obj;
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
exports.instrumentDurableObjectWithSentry = instrumentDurableObjectWithSentry;
|
|
213
|
+
//# sourceMappingURL=durableobject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durableobject.js","sources":["../../src/durableobject.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\nimport {\n captureException,\n flush,\n getClient,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startSpan,\n withIsolationScope,\n withScope,\n} from '@sentry/core';\nimport type { DurableObject } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from './async';\nimport type { CloudflareOptions } from './client';\nimport { isInstrumented, markAsInstrumented } from './instrument';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandler } from './request';\nimport { init } from './sdk';\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\nfunction wrapMethodWithSentry<T extends (...args: any[]) => any>(\n wrapperOptions: MethodWrapperOptions,\n handler: T,\n callback?: (...args: Parameters<T>) => void,\n): T {\n if (isInstrumented(handler)) {\n return handler;\n }\n\n markAsInstrumented(handler);\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 return sentryWithScope(async scope => {\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 ExecutionContext | undefined;\n\n const currentClient = scope.getClient();\n if (!currentClient) {\n const client = init(wrapperOptions.options);\n scope.setClient(client);\n }\n\n if (!wrapperOptions.spanName) {\n try {\n if (callback) {\n callback(...args);\n }\n return await Reflect.apply(target, thisArg, args);\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'cloudflare_durableobject',\n handled: false,\n },\n });\n throw e;\n } finally {\n context?.waitUntil(flush(2000));\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare_durableobjects',\n }\n : {};\n\n // Only create these spans if they have a parent span.\n return startSpan({ name: wrapperOptions.spanName, attributes, onlyIfParent: true }, async () => {\n try {\n return await Reflect.apply(target, thisArg, args);\n } catch (e) {\n captureException(e, {\n mechanism: {\n type: 'cloudflare_durableobject',\n handled: false,\n },\n });\n throw e;\n } finally {\n context?.waitUntil(flush(2000));\n }\n });\n });\n },\n });\n}\n\n/**\n * Instruments a Durable Object class to capture errors and performance data.\n *\n * Instruments the following methods:\n * - fetch\n * - alarm\n * - webSocketMessage\n * - webSocketClose\n * - webSocketError\n *\n * as well as any other public RPC methods on the Durable Object instance.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param DurableObjectClass The Durable Object class to instrument.\n * @returns The instrumented Durable Object class.\n *\n * @example\n * ```ts\n * class MyDurableObjectBase extends DurableObject {\n * constructor(ctx: DurableObjectState, env: Env) {\n * super(ctx, env);\n * }\n * }\n *\n * export const MyDurableObject = instrumentDurableObjectWithSentry(\n * env => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }),\n * MyDurableObjectBase,\n * );\n * ```\n */\nexport function instrumentDurableObjectWithSentry<E, T extends DurableObject<E>>(\n optionsCallback: (env: E) => CloudflareOptions,\n DurableObjectClass: new (state: DurableObjectState, env: E) => T,\n): new (state: DurableObjectState, env: E) => T {\n return new Proxy(DurableObjectClass, {\n construct(target, [context, env]) {\n setAsyncLocalStorageAsyncContextStrategy();\n\n const options = getFinalOptions(optionsCallback(env), env);\n\n const obj = new target(context, env);\n\n // These are the methods that are available on a Durable Object\n // ref: https://developers.cloudflare.com/durable-objects/api/base/\n // obj.alarm\n // obj.fetch\n // obj.webSocketError\n // obj.webSocketClose\n // obj.webSocketMessage\n\n // Any other public methods on the Durable Object instance are RPC calls.\n\n if (obj.fetch && typeof obj.fetch === 'function' && !isInstrumented(obj.fetch)) {\n obj.fetch = new Proxy(obj.fetch, {\n apply(target, thisArg, args) {\n return wrapRequestHandler({ options, request: args[0], context }, () =>\n Reflect.apply(target, thisArg, args),\n );\n },\n });\n\n markAsInstrumented(obj.fetch);\n }\n\n if (obj.alarm && typeof obj.alarm === 'function') {\n obj.alarm = wrapMethodWithSentry({ options, context, spanName: 'alarm' }, obj.alarm);\n }\n\n if (obj.webSocketMessage && typeof obj.webSocketMessage === 'function') {\n obj.webSocketMessage = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketMessage' },\n obj.webSocketMessage,\n );\n }\n\n if (obj.webSocketClose && typeof obj.webSocketClose === 'function') {\n obj.webSocketClose = wrapMethodWithSentry({ options, context, spanName: 'webSocketClose' }, obj.webSocketClose);\n }\n\n if (obj.webSocketError && typeof obj.webSocketError === 'function') {\n obj.webSocketError = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketError' },\n obj.webSocketError,\n (_, error) =>\n captureException(error, {\n mechanism: {\n type: 'cloudflare_durableobject_websocket',\n handled: false,\n },\n }),\n );\n }\n\n for (const method of Object.getOwnPropertyNames(obj)) {\n if (\n method === 'fetch' ||\n method === 'alarm' ||\n method === 'webSocketError' ||\n method === 'webSocketClose' ||\n method === 'webSocketMessage'\n ) {\n continue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n const value = (obj as any)[method] as unknown;\n if (typeof value === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n (obj as any)[method] = wrapMethodWithSentry(\n { options, context, spanName: method, spanOp: 'rpc' },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value as (...args: any[]) => any,\n );\n }\n }\n\n return obj;\n },\n });\n}\n"],"names":["isInstrumented","markAsInstrumented","getClient","withScope","withIsolationScope","init","captureException","flush","SEMANTIC_ATTRIBUTE_SENTRY_OP","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","startSpan","setAsyncLocalStorageAsyncContextStrategy","options","getFinalOptions","wrapRequestHandler"],"mappings":";;;;;;;;;AAAA;;AA0BA;AACA,SAAS,oBAAoB;AAC7B,EAAE,cAAc;AAChB,EAAE,OAAO;AACT,EAAE,QAAQ;AACV,EAAK;AACL,EAAE,IAAIA,yBAAc,CAAC,OAAO,CAAC,EAAE;AAC/B,IAAI,OAAO,OAAO;AAClB;;AAEA,EAAEC,6BAAkB,CAAC,OAAO,CAAC;;AAE7B,EAAE,OAAO,IAAI,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
|
|
4
4
|
const async = require('./async.js');
|
|
5
|
+
const instrument = require('./instrument.js');
|
|
6
|
+
const options = require('./options.js');
|
|
5
7
|
const request = require('./request.js');
|
|
6
8
|
const scopeUtils = require('./scope-utils.js');
|
|
7
9
|
const sdk = require('./sdk.js');
|
|
8
10
|
|
|
9
|
-
/**
|
|
10
|
-
* Extract environment generic from exported handler.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
11
|
/**
|
|
14
12
|
* Wrapper for Cloudflare handlers.
|
|
15
13
|
*
|
|
@@ -21,83 +19,75 @@ const sdk = require('./sdk.js');
|
|
|
21
19
|
* @param handler {ExportedHandler} The handler to wrap.
|
|
22
20
|
* @returns The wrapped handler.
|
|
23
21
|
*/
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
22
|
function withSentry(
|
|
26
23
|
optionsCallback,
|
|
27
24
|
handler,
|
|
28
25
|
) {
|
|
29
26
|
async.setAsyncLocalStorageAsyncContextStrategy();
|
|
30
27
|
|
|
31
|
-
|
|
32
|
-
handler.fetch
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return request.wrapRequestHandler({ options, request: request$1, context }, () => target.apply(thisArg, args));
|
|
37
|
-
},
|
|
38
|
-
});
|
|
28
|
+
try {
|
|
29
|
+
if ('fetch' in handler && typeof handler.fetch === 'function' && !instrument.isInstrumented(handler.fetch)) {
|
|
30
|
+
handler.fetch = new Proxy(handler.fetch, {
|
|
31
|
+
apply(target, thisArg, args) {
|
|
32
|
+
const [request$1, env, context] = args;
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
}
|
|
34
|
+
const options$1 = options.getFinalOptions(optionsCallback(env), env);
|
|
42
35
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const [event, env, context] = args;
|
|
47
|
-
return core.withIsolationScope(isolationScope => {
|
|
48
|
-
const options = optionsCallback(env);
|
|
49
|
-
const client = sdk.init(options);
|
|
50
|
-
isolationScope.setClient(client);
|
|
36
|
+
return request.wrapRequestHandler({ options: options$1, request: request$1, context }, () => target.apply(thisArg, args));
|
|
37
|
+
},
|
|
38
|
+
});
|
|
51
39
|
|
|
52
|
-
|
|
40
|
+
instrument.markAsInstrumented(handler.fetch);
|
|
41
|
+
}
|
|
53
42
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
'faas.time': new Date(event.scheduledTime).toISOString(),
|
|
61
|
-
'faas.trigger': 'timer',
|
|
62
|
-
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',
|
|
63
|
-
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
async () => {
|
|
67
|
-
try {
|
|
68
|
-
return await (target.apply(thisArg, args) );
|
|
69
|
-
} catch (e) {
|
|
70
|
-
core.captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
|
|
71
|
-
throw e;
|
|
72
|
-
} finally {
|
|
73
|
-
context.waitUntil(core.flush(2000));
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
});
|
|
43
|
+
if ('scheduled' in handler && typeof handler.scheduled === 'function' && !instrument.isInstrumented(handler.scheduled)) {
|
|
44
|
+
handler.scheduled = new Proxy(handler.scheduled, {
|
|
45
|
+
apply(target, thisArg, args) {
|
|
46
|
+
const [event, env, context] = args;
|
|
47
|
+
return core.withIsolationScope(isolationScope => {
|
|
48
|
+
const options$1 = options.getFinalOptions(optionsCallback(env), env);
|
|
80
49
|
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
const client = sdk.init(options$1);
|
|
51
|
+
isolationScope.setClient(client);
|
|
83
52
|
|
|
84
|
-
|
|
85
|
-
}
|
|
53
|
+
scopeUtils.addCloudResourceContext(isolationScope);
|
|
86
54
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
55
|
+
return core.startSpan(
|
|
56
|
+
{
|
|
57
|
+
op: 'faas.cron',
|
|
58
|
+
name: `Scheduled Cron ${event.cron}`,
|
|
59
|
+
attributes: {
|
|
60
|
+
'faas.cron': event.cron,
|
|
61
|
+
'faas.time': new Date(event.scheduledTime).toISOString(),
|
|
62
|
+
'faas.trigger': 'timer',
|
|
63
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.faas.cloudflare',
|
|
64
|
+
[core.SEMANTIC_ATTRIBUTE_SENTRY_SOURCE]: 'task',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
async () => {
|
|
68
|
+
try {
|
|
69
|
+
return await (target.apply(thisArg, args) );
|
|
70
|
+
} catch (e) {
|
|
71
|
+
core.captureException(e, { mechanism: { handled: false, type: 'cloudflare' } });
|
|
72
|
+
throw e;
|
|
73
|
+
} finally {
|
|
74
|
+
context.waitUntil(core.flush(2000));
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
});
|
|
94
81
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
82
|
+
instrument.markAsInstrumented(handler.scheduled);
|
|
83
|
+
}
|
|
84
|
+
// This is here because Miniflare sometimes cannot get instrumented
|
|
85
|
+
//
|
|
86
|
+
} catch (e) {
|
|
87
|
+
// Do not console anything here, we don't want to spam the console with errors
|
|
100
88
|
}
|
|
89
|
+
|
|
90
|
+
return handler;
|
|
101
91
|
}
|
|
102
92
|
|
|
103
93
|
exports.withSentry = withSentry;
|
package/build/cjs/handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sources":["../../src/handler.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"handler.js","sources":["../../src/handler.ts"],"sourcesContent":["import {\n captureException,\n flush,\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 { isInstrumented, markAsInstrumented } from './instrument';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandler } from './request';\nimport { addCloudResourceContext } from './scope-utils';\nimport { init } from './sdk';\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 */\nexport function withSentry<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown>(\n optionsCallback: (env: Env) => CloudflareOptions,\n handler: ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata>,\n): ExportedHandler<Env, QueueHandlerMessage, CfHostMetadata> {\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, context] = args;\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 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, context] = args;\n return withIsolationScope(isolationScope => {\n const options = getFinalOptions(optionsCallback(env), env);\n\n const client = init(options);\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',\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: 'cloudflare' } });\n throw e;\n } finally {\n context.waitUntil(flush(2000));\n }\n },\n );\n });\n },\n });\n\n markAsInstrumented(handler.scheduled);\n }\n // This is here because Miniflare sometimes cannot get instrumented\n //\n } catch (e) {\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","options","getFinalOptions","wrapRequestHandler","markAsInstrumented","withIsolationScope","init","addCloudResourceContext","startSpan","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","SEMANTIC_ATTRIBUTE_SENTRY_SOURCE","captureException","flush"],"mappings":";;;;;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,UAAU;AAC1B,EAAE,eAAe;AACjB,EAAE,OAAO;AACT,EAA6D;AAC7D,EAAEA,8CAAwC,EAAE;;AAE5C,EAAE,IAAI;AACN,IAAI,IAAI,OAAQ,IAAG,WAAW,OAAO,OAAO,CAAC,KAAA,KAAU,UAAW,IAAG,CAACC,yBAAc,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,CAACC,SAAO,EAAE,GAAG,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CAAA,KAAA,CAAA,aAAA,CAAA,CAAA,WAAA,EAAA;AACA,kBAAA,cAAA,EAAA,OAAA;AACA,kBAAA,CAAAC,qCAAA,GAAA,sBAAA;AACA,kBAAA,CAAAC,qCAAA,GAAA,MAAA;AACA,iBAAA;AACA,eAAA;AACA,cAAA,YAAA;AACA,gBAAA,IAAA;AACA,kBAAA,OAAA,OAAA,MAAA,CAAA,KAAA,CAAA,OAAA,EAAA,IAAA,CAAA,EAAA;AACA,iBAAA,CAAA,OAAA,CAAA,EAAA;AACA,kBAAAC,qBAAA,CAAA,CAAA,EAAA,EAAA,SAAA,EAAA,EAAA,OAAA,EAAA,KAAA,EAAA,IAAA,EAAA,YAAA,EAAA,EAAA,CAAA;AACA,kBAAA,MAAA,CAAA;AACA,iBAAA,SAAA;AACA,kBAAA,OAAA,CAAA,SAAA,CAAAC,UAAA,CAAA,IAAA,CAAA,CAAA;AACA;AACA,eAAA;AACA,aAAA;AACA,WAAA,CAAA;AACA,SAAA;AACA,OAAA,CAAA;;AAEA,MAAAR,6BAAA,CAAA,OAAA,CAAA,SAAA,CAAA;AACA;AACA;AACA;AACA,GAAA,CAAA,OAAA,CAAA,EAAA;AACA;AACA;;AAEA,EAAA,OAAA,OAAA;AACA;;;;"}
|
package/build/cjs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
|
|
3
3
|
const core = require('@sentry/core');
|
|
4
|
+
const exports$1 = require('./logs/exports.js');
|
|
4
5
|
const handler = require('./handler.js');
|
|
6
|
+
const durableobject = require('./durableobject.js');
|
|
5
7
|
const pagesPlugin = require('./pages-plugin.js');
|
|
6
8
|
const request = require('./request.js');
|
|
7
9
|
const client = require('./client.js');
|
|
@@ -29,6 +31,7 @@ exports.captureFeedback = core.captureFeedback;
|
|
|
29
31
|
exports.captureMessage = core.captureMessage;
|
|
30
32
|
exports.close = core.close;
|
|
31
33
|
exports.consoleIntegration = core.consoleIntegration;
|
|
34
|
+
exports.consoleLoggingIntegration = core.consoleLoggingIntegration;
|
|
32
35
|
exports.continueTrace = core.continueTrace;
|
|
33
36
|
exports.createTransport = core.createTransport;
|
|
34
37
|
exports.dedupeIntegration = core.dedupeIntegration;
|
|
@@ -78,8 +81,11 @@ exports.withActiveSpan = core.withActiveSpan;
|
|
|
78
81
|
exports.withIsolationScope = core.withIsolationScope;
|
|
79
82
|
exports.withMonitor = core.withMonitor;
|
|
80
83
|
exports.withScope = core.withScope;
|
|
84
|
+
exports.wrapMcpServerWithSentry = core.wrapMcpServerWithSentry;
|
|
81
85
|
exports.zodErrorsIntegration = core.zodErrorsIntegration;
|
|
86
|
+
exports.logger = exports$1;
|
|
82
87
|
exports.withSentry = handler.withSentry;
|
|
88
|
+
exports.instrumentDurableObjectWithSentry = durableobject.instrumentDurableObjectWithSentry;
|
|
83
89
|
exports.sentryPagesPlugin = pagesPlugin.sentryPagesPlugin;
|
|
84
90
|
exports.wrapRequestHandler = request.wrapRequestHandler;
|
|
85
91
|
exports.CloudflareClient = client.CloudflareClient;
|
package/build/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mark an object as instrumented.
|
|
5
|
+
*/
|
|
6
|
+
function markAsInstrumented(obj) {
|
|
7
|
+
try {
|
|
8
|
+
(obj ).__SENTRY_INSTRUMENTED__ = true;
|
|
9
|
+
} catch {
|
|
10
|
+
// ignore errors here
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Check if an object is instrumented.
|
|
16
|
+
*/
|
|
17
|
+
function isInstrumented(obj) {
|
|
18
|
+
try {
|
|
19
|
+
return (obj ).__SENTRY_INSTRUMENTED__;
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.isInstrumented = isInstrumented;
|
|
26
|
+
exports.markAsInstrumented = markAsInstrumented;
|
|
27
|
+
//# sourceMappingURL=instrument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.js","sources":["../../src/instrument.ts"],"sourcesContent":["type SentryInstrumented<T> = T & {\n __SENTRY_INSTRUMENTED__?: boolean;\n};\n\n/**\n * Mark an object as instrumented.\n */\nexport function markAsInstrumented<T>(obj: T): void {\n try {\n (obj as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__ = true;\n } catch {\n // ignore errors here\n }\n}\n\n/**\n * Check if an object is instrumented.\n */\nexport function isInstrumented<T>(obj: T): boolean | undefined {\n try {\n return (obj as SentryInstrumented<T>).__SENTRY_INSTRUMENTED__;\n } catch {\n return false;\n }\n}\n"],"names":[],"mappings":";;AAIA;AACA;AACA;AACO,SAAS,kBAAkB,CAAI,GAAG,EAAW;AACpD,EAAE,IAAI;AACN,IAAI,CAAC,GAAI,GAA0B,uBAAA,GAA0B,IAAI;AACjE,IAAI,MAAM;AACV;AACA;AACA;;AAEA;AACA;AACA;AACO,SAAS,cAAc,CAAI,GAAG,EAA0B;AAC/D,EAAE,IAAI;AACN,IAAI,OAAO,CAAC,GAAI,GAA0B,uBAAuB;AACjE,IAAI,MAAM;AACV,IAAI,OAAO,KAAK;AAChB;AACA;;;;;"}
|