@sentry/cloudflare 10.68.0 → 10.70.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 +5 -0
- package/build/cjs/client.js.map +1 -1
- package/build/cjs/durableobject.js +210 -97
- package/build/cjs/durableobject.js.map +1 -1
- package/build/cjs/flush.js.map +1 -1
- package/build/cjs/index.js +3 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/instrumentations/agents/index.js +16 -0
- package/build/cjs/instrumentations/agents/index.js.map +1 -0
- package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
- package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/cjs/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
- package/build/cjs/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
- package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/cjs/instrumentations/agents/types.js +77 -0
- package/build/cjs/instrumentations/agents/types.js.map +1 -0
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js +6 -0
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js +1 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/integrations/spotlight.js +64 -0
- package/build/cjs/integrations/spotlight.js.map +1 -0
- package/build/cjs/nodejs_compat/index.js +5 -2
- package/build/cjs/nodejs_compat/index.js.map +1 -1
- package/build/cjs/options.js +14 -1
- package/build/cjs/options.js.map +1 -1
- package/build/cjs/request.js +3 -2
- package/build/cjs/request.js.map +1 -1
- package/build/cjs/sdk.js +8 -0
- package/build/cjs/sdk.js.map +1 -1
- package/build/cjs/utils/internalSqlQuery.js +13 -7
- package/build/cjs/utils/internalSqlQuery.js.map +1 -1
- package/build/cjs/utils/internalStorageKey.js +44 -0
- package/build/cjs/utils/internalStorageKey.js.map +1 -0
- package/build/cjs/utils/invocationScope.js +12 -0
- package/build/cjs/utils/invocationScope.js.map +1 -0
- package/build/cjs/utils/rpcMeta.js +4 -0
- package/build/cjs/utils/rpcMeta.js.map +1 -1
- package/build/cjs/vite/agentClass.js +114 -0
- package/build/cjs/vite/agentClass.js.map +1 -0
- package/build/cjs/vite/autoInstrument.js +17 -4
- package/build/cjs/vite/autoInstrument.js.map +1 -1
- package/build/cjs/vite/index.js +1 -1
- package/build/cjs/vite/index.js.map +1 -1
- package/build/cjs/vite/moduleShape.js +231 -0
- package/build/cjs/vite/moduleShape.js.map +1 -0
- package/build/cjs/vite/transform.js +6 -1
- package/build/cjs/vite/transform.js.map +1 -1
- package/build/cjs/vite/wranglerConfig.js +1 -1
- package/build/cjs/vite/wranglerConfig.js.map +1 -1
- package/build/cjs/workflows.js +1 -1
- package/build/cjs/workflows.js.map +1 -1
- package/build/cjs/wrapMethodWithSentry.js +2 -3
- package/build/cjs/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/client.js +6 -1
- package/build/esm/client.js.map +1 -1
- package/build/esm/durableobject.js +211 -101
- package/build/esm/durableobject.js.map +1 -1
- package/build/esm/flush.js.map +1 -1
- package/build/esm/index.js +2 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/instrumentations/agents/index.js +14 -0
- package/build/esm/instrumentations/agents/index.js.map +1 -0
- package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
- package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/esm/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
- package/build/esm/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
- package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/esm/instrumentations/agents/types.js +69 -0
- package/build/esm/instrumentations/agents/types.js.map +1 -0
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js +7 -1
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js +1 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/integrations/spotlight.js +61 -0
- package/build/esm/integrations/spotlight.js.map +1 -0
- package/build/esm/nodejs_compat/index.js +2 -1
- package/build/esm/nodejs_compat/index.js.map +1 -1
- package/build/esm/options.js +14 -1
- package/build/esm/options.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/request.js +4 -3
- package/build/esm/request.js.map +1 -1
- package/build/esm/sdk.js +8 -0
- package/build/esm/sdk.js.map +1 -1
- package/build/esm/utils/internalSqlQuery.js +13 -7
- package/build/esm/utils/internalSqlQuery.js.map +1 -1
- package/build/esm/utils/internalStorageKey.js +41 -0
- package/build/esm/utils/internalStorageKey.js.map +1 -0
- package/build/esm/utils/invocationScope.js +10 -0
- package/build/esm/utils/invocationScope.js.map +1 -0
- package/build/esm/utils/rpcMeta.js +4 -1
- package/build/esm/utils/rpcMeta.js.map +1 -1
- package/build/esm/utils/traceLinks.js +1 -1
- package/build/esm/vite/agentClass.js +111 -0
- package/build/esm/vite/agentClass.js.map +1 -0
- package/build/esm/vite/autoInstrument.js +17 -4
- package/build/esm/vite/autoInstrument.js.map +1 -1
- package/build/esm/vite/index.js +1 -1
- package/build/esm/vite/index.js.map +1 -1
- package/build/esm/vite/moduleShape.js +227 -0
- package/build/esm/vite/moduleShape.js.map +1 -0
- package/build/esm/vite/transform.js +6 -1
- package/build/esm/vite/transform.js.map +1 -1
- package/build/esm/vite/wranglerConfig.js +1 -1
- package/build/esm/vite/wranglerConfig.js.map +1 -1
- package/build/esm/workflows.js +2 -2
- package/build/esm/workflows.js.map +1 -1
- package/build/esm/wrapMethodWithSentry.js +3 -4
- package/build/esm/wrapMethodWithSentry.js.map +1 -1
- package/build/types/client.d.ts +37 -0
- package/build/types/client.d.ts.map +1 -1
- package/build/types/durableobject.d.ts +90 -0
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/flush.d.ts +1 -1
- package/build/types/flush.d.ts.map +1 -1
- package/build/types/index.d.ts +2 -1
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/agents/index.d.ts +25 -0
- package/build/types/instrumentations/agents/index.d.ts.map +1 -0
- package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts +14 -0
- package/build/types/instrumentations/agents/instrumentAgentCallableRpc.d.ts.map +1 -0
- package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
- package/build/types/instrumentations/agents/instrumentAgentRequestConversation.d.ts.map +1 -0
- package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts +23 -0
- package/build/types/instrumentations/agents/instrumentChatAgentConversation.d.ts.map +1 -0
- package/build/types/instrumentations/agents/types.d.ts +94 -0
- package/build/types/instrumentations/agents/types.d.ts.map +1 -0
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
- package/build/types/integrations/spotlight.d.ts +22 -0
- package/build/types/integrations/spotlight.d.ts.map +1 -0
- package/build/types/options.d.ts.map +1 -1
- package/build/types/request.d.ts.map +1 -1
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/utils/internalSqlQuery.d.ts +4 -2
- package/build/types/utils/internalSqlQuery.d.ts.map +1 -1
- package/build/types/utils/internalStorageKey.d.ts +22 -0
- package/build/types/utils/internalStorageKey.d.ts.map +1 -0
- package/build/types/utils/invocationScope.d.ts +24 -0
- package/build/types/utils/invocationScope.d.ts.map +1 -0
- package/build/types/utils/rpcMeta.d.ts +8 -0
- package/build/types/utils/rpcMeta.d.ts.map +1 -1
- package/build/types/vite/agentClass.d.ts +41 -0
- package/build/types/vite/agentClass.d.ts.map +1 -0
- package/build/types/vite/autoInstrument.d.ts +7 -6
- package/build/types/vite/autoInstrument.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +14 -4
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/moduleShape.d.ts +52 -0
- package/build/types/vite/moduleShape.d.ts.map +1 -0
- package/build/types/vite/transform.d.ts +6 -1
- package/build/types/vite/transform.d.ts.map +1 -1
- package/build/types/wrapMethodWithSentry.d.ts +1 -1
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/build/types-ts3.8/client.d.ts +37 -0
- package/build/types-ts3.8/durableobject.d.ts +90 -0
- package/build/types-ts3.8/flush.d.ts +1 -1
- package/build/types-ts3.8/index.d.ts +2 -1
- package/build/types-ts3.8/instrumentations/agents/index.d.ts +25 -0
- package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +14 -0
- package/build/types-ts3.8/instrumentations/agents/instrumentAgentRequestConversation.d.ts +16 -0
- package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +23 -0
- package/build/types-ts3.8/instrumentations/agents/types.d.ts +94 -0
- package/build/types-ts3.8/integrations/spotlight.d.ts +22 -0
- package/build/types-ts3.8/utils/internalSqlQuery.d.ts +4 -2
- package/build/types-ts3.8/utils/internalStorageKey.d.ts +22 -0
- package/build/types-ts3.8/utils/invocationScope.d.ts +24 -0
- package/build/types-ts3.8/utils/rpcMeta.d.ts +8 -0
- package/build/types-ts3.8/vite/agentClass.d.ts +41 -0
- package/build/types-ts3.8/vite/autoInstrument.d.ts +7 -6
- package/build/types-ts3.8/vite/index.d.ts +14 -4
- package/build/types-ts3.8/vite/moduleShape.d.ts +52 -0
- package/build/types-ts3.8/vite/transform.d.ts +6 -1
- package/build/types-ts3.8/wrapMethodWithSentry.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\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 type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { extractRpcMeta } from './utils/rpcMeta';\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\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\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 * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\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, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\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 // see: https://github.com/getsentry/sentry-javascript/issues/22328\n const waitUntil = context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\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 storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\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(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\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 try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\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":";;;;;;;AAkCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAI,YAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,MAAA,OAAO,KAAA,CAAM,eAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,IAAW,iBAAA,IAAqB,OAAA,IAAW,OAAA,CAAQ,eAAA,EAAiB;AACtE,IAAA,OAAO,OAAA,CAAQ,eAAA;AAAA,EACjB;AAEA,EAAA,OAAO,MAAA;AACT;AAuCO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAO,kBAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,MAClB,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAwB;AAC7C,QAAA,MAAM,iBAAEA,eAAA,EAAe,MAAA,EAAO,GAAI,cAAA;AAKlC,QAAA,IAAI,IAAA,GAAO,OAAA;AACX,QAAA,IAAI,OAAA;AAEJ,QAAA,IAAI,cAAA,CAAe,WAAW,KAAA,EAAO;AACnC,UAAA,MAAM,SAAA,GAAY,eAAe,OAAO,CAAA;AACxC,UAAA,IAAA,GA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AM,WAAA,GAAc,aAAA,CAAc,OAAA,GAAU,GAAA,GAAM,GAAA;AAClD,kBAAA,IAAA,CAAK,YAAA;AAAA,oBACH,uBAAA;AAAA,oBACA,GAAG,aAAA,CAAc,OAAO,IAAI,aAAA,CAAc,MAAM,IAAI,WAAW,CAAA;AAAA,mBACjE;AAAA,gBACF;AAAA,cACF;AAEA,cAAA,IAAI;AACF,gBAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,SAAS,IAAI,CAAA;AAElD,gBAAA,IAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AACtB,kBAAA,OAAO,MAAA,CAAO,IAAA,CAAK,WAAA,EAAa,UAAU,CAAA;AAAA,gBAC5C,CAAA,MAAO;AACL,kBAAA,OAAO,YAAY,MAAM,CAAA;AAAA,gBAC3B;AAAA,cACF,SAAS,CAAA,EAAG;AACV,gBAAA,OAAO,WAAW,CAAC,CAAA;AAAA,cACrB;AAAA,YACF,CAAC,CAAA;AAAA,UACH,CAAA;AAEA,UAAA,IAAI,OAAA,EAAS;AACX,YAAA,OAAO,aAAA;AAAA,cACL,EAAE,aAAa,OAAA,CAAQ,cAAc,KAAK,EAAA,EAAI,OAAA,EAAS,OAAA,CAAQ,OAAA,IAAW,EAAA,EAAG;AAAA,cAC7E;AAAA,aACF;AAAA,UACF;AAEA,UAAA,IAAIA,eAAA,EAAe;AACjB,YAAA,OAAOC,aAAA,CAAkB,MAAM,WAAA,EAAa,CAAA;AAAA,UAC9C;AAEA,UAAA,OAAO,WAAA,EAAY;AAAA,QACrB,CAAA;AAEA,QAAA,OAAO,gBAAgB,eAAe,CAAA;AAAA,MACxC;AAAA,KACD,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"wrapMethodWithSentry.js","sources":["../../src/wrapMethodWithSentry.ts"],"sourcesContent":["import type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport type { SerializedTraceData } from '@sentry/core';\nimport {\n isObjectLike,\n captureException,\n continueTrace,\n isThenable,\n type Scope,\n SEMANTIC_ATTRIBUTE_SENTRY_OP,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n startNewTrace as startNewTraceCore,\n startSpan,\n} from '@sentry/core';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { flushAndDispose, getOriginalWaitUntil } from './flush';\nimport { ensureInstrumented } from './instrument';\nimport { init } from './sdk';\nimport { withInvocationIsolationScope } from './utils/invocationScope';\nimport { extractRpcMeta } from './utils/rpcMeta';\nimport { buildSpanLinks, getStoredSpanContext, storeSpanContext } from './utils/traceLinks';\n\n/** Extended DurableObjectState with originalStorage exposed by instrumentContext */\nexport interface InstrumentedDurableObjectState extends DurableObjectState {\n originalStorage?: DurableObjectStorage;\n}\n\n/**\n * Resolves uninstrumented DO storage for the current invocation.\n * Prefer `thisArg.ctx` (the live Durable Object instance) over the context captured at\n * construction time to avoid cross-DO I/O errors in the same isolate.\n */\nfunction resolveOriginalStorage(\n context: ExecutionContext | InstrumentedDurableObjectState | undefined,\n thisArg: unknown,\n): DurableObjectStorage | undefined {\n if (isObjectLike(thisArg) && 'ctx' in thisArg) {\n const doCtx = (thisArg as { ctx: InstrumentedDurableObjectState }).ctx;\n if (doCtx?.originalStorage) {\n return doCtx.originalStorage;\n }\n }\n\n if (context && 'originalStorage' in context && context.originalStorage) {\n return context.originalStorage;\n }\n\n return undefined;\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 * The trace origin identifying which instrumentation created the span, e.g. `auto.faas.cloudflare.durable_object`.\n * Used both as the span's `sentry.origin` attribute and as the `mechanism.type` for captured exceptions.\n */\n origin: string;\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, rawArgs: Parameters<T>) {\n const { startNewTrace, origin } = wrapperOptions;\n\n // For RPC methods, extract Sentry trace context from the trailing argument.\n // The caller side (instrumentDurableObjectStub / JSRPC proxy) appends it;\n // we strip it here so the user's method never sees it.\n let args = rawArgs;\n let rpcMeta: SerializedTraceData | undefined;\n\n if (wrapperOptions.spanOp === 'rpc') {\n const extracted = extractRpcMeta(rawArgs);\n args = extracted.args;\n rpcMeta = extracted.rpcMeta;\n }\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 // see: https://github.com/getsentry/sentry-javascript/issues/22328\n const waitUntil = context\n ? getOriginalWaitUntil(context as ExecutionContextCompat)?.bind(context)\n : undefined;\n const storage = resolveOriginalStorage(context, thisArg);\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 storeSpanContext(storage, methodName);\n }\n await flushAndDispose(clientToDispose);\n };\n\n const onFulfilled = (res: unknown) => {\n waitUntil?.(teardown());\n return res;\n };\n\n const onRejected = (e: unknown) => {\n captureException(e, {\n mechanism: {\n type: origin,\n handled: false,\n },\n });\n waitUntil?.(teardown());\n throw e;\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(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n }\n\n const attributes = wrapperOptions.spanOp\n ? {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: wrapperOptions.spanOp,\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: origin,\n }\n : {};\n\n const executeSpan = (): unknown => {\n return startSpan({ name: methodName, attributes }, span => {\n if (startNewTrace && storage) {\n const storedContext = getStoredSpanContext(storage, methodName);\n\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 try {\n const result = Reflect.apply(target, thisArg, args);\n\n if (isThenable(result)) {\n return result.then(onFulfilled, onRejected);\n } else {\n return onFulfilled(result);\n }\n } catch (e) {\n return onRejected(e);\n }\n });\n };\n\n if (rpcMeta) {\n return continueTrace(\n { sentryTrace: rpcMeta['sentry-trace'] || '', baggage: rpcMeta.baggage || '' },\n executeSpan,\n );\n }\n\n if (startNewTrace) {\n return startNewTraceCore(() => executeSpan());\n }\n\n return executeSpan();\n };\n\n return withInvocationIsolationScope(wrappedFunction);\n },\n }),\n noMark,\n );\n}\n"],"names":["startNewTrace","startNewTraceCore"],"mappings":";;;;;;;;AAgCA,SAAS,sBAAA,CACP,SACA,OAAA,EACkC;AAClC,EAAA,IAAI,YAAA,CAAa,OAAO,CAAA,IAAK,KAAA,IAAS,OAAA,EAAS;AAC7C,IAAA,MAAM,QAAS,OAAA,CAAoD,GAAA;AACnE,IAAA,IAAI,OAAO,eAAA,EAAiB;AAC1B,MAAA,OAAO,KAAA,CAAM,eAAA;AAAA,IACf;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,IAAW,iBAAA,IAAqB,OAAA,IAAW,OAAA,CAAQ,eAAA,EAAiB;AACtE,IAAA,OAAO,OAAA,CAAQ,eAAA;AAAA,EACjB;AAEA,EAAA,OAAO,MAAA;AACT;AAuCO,SAAS,oBAAA,CACd,cAAA,EACA,OAAA,EACA,QAAA,EACA,MAAA,EACG;AACH,EAAA,OAAO,kBAAA;AAAA,IACL,OAAA;AAAA,IACA,CAAA,QAAA,KACE,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,MAClB,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,OAAA,EAAwB;AAC7C,QAAA,MAAM,iBAAEA,eAAA,EAAe,MAAA,EAAO,GAAI,cAAA;AAKlC,QAAA,IAAI,IAAA,GAAO,OAAA;AACX,QAAA,IAAI,OAAA;AAEJ,QAAA,IAAI,cAAA,CAAe,WAAW,KAAA,EAAO;AACnC,UAAA,MAAM,SAAA,GAAY,eAAe,OAAO,CAAA;AACxC,UAAA,IAAA,GAAO,SAAA,CAAU,IAAA;AACjB,UAAA,OAAA,GAAU,SAAA,CAAU,OAAA;AAAA,QAC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,gBACF;AAAA,cACF;AAEA,cAAA,IAAI;AACF,gBAAA,MAAM,MAAA,GAAS,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,SAAS,IAAI,CAAA;AAElD,gBAAA,IAAI,UAAA,CAAW,MAAM,CAAA,EAAG;AACtB,kBAAA,OAAO,MAAA,CAAO,IAAA,CAAK,WAAA,EAAa,UAAU,CAAA;AAAA,gBAC5C,CAAA,MAAO;AACL,kBAAA,OAAO,YAAY,MAAM,CAAA;AAAA,gBAC3B;AAAA,cACF,SAAS,CAAA,EAAG;AACV,gBAAA,OAAO,WAAW,CAAC,CAAA;AAAA,cACrB;AAAA,YACF,CAAC,CAAA;AAAA,UACH,CAAA;AAEA,UAAA,IAAI,OAAA,EAAS;AACX,YAAA,OAAO,aAAA;AAAA,cACL,EAAE,aAAa,OAAA,CAAQ,cAAc,KAAK,EAAA,EAAI,OAAA,EAAS,OAAA,CAAQ,OAAA,IAAW,EAAA,EAAG;AAAA,cAC7E;AAAA,aACF;AAAA,UACF;AAEA,UAAA,IAAIA,eAAA,EAAe;AACjB,YAAA,OAAOC,aAAA,CAAkB,MAAM,WAAA,EAAa,CAAA;AAAA,UAC9C;AAEA,UAAA,OAAO,WAAA,EAAY;AAAA,QACrB,CAAA;AAEA,QAAA,OAAO,6BAA6B,eAAe,CAAA;AAAA,MACrD;AAAA,KACD,CAAA;AAAA,IACH;AAAA,GACF;AACF;;;;"}
|
package/build/types/client.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export declare class CloudflareClient extends ServerRuntimeClient {
|
|
|
41
41
|
* After calling dispose(), the client should not be used anymore.
|
|
42
42
|
*/
|
|
43
43
|
dispose(): void;
|
|
44
|
+
/** @inheritDoc */
|
|
45
|
+
protected _setupIntegrations(): void;
|
|
44
46
|
/**
|
|
45
47
|
* Resets the span completion promise and resolve function.
|
|
46
48
|
*/
|
|
@@ -132,6 +134,30 @@ interface BaseCloudflareOptions {
|
|
|
132
134
|
* ```
|
|
133
135
|
*/
|
|
134
136
|
durableObjectSqlSpanAllowlist?: Array<string | RegExp>;
|
|
137
|
+
/**
|
|
138
|
+
* KV keys that should stay instrumented even though they match a reserved prefix used by Durable
|
|
139
|
+
* Object frameworks (`agents`, `partyserver`, ...) for their internal storage entries.
|
|
140
|
+
*
|
|
141
|
+
* By default, KV reads/writes (`get`, `put`, `delete`, `list`) of `cf_`- or `__ps_`-prefixed keys
|
|
142
|
+
* are treated as framework noise and no `durable_object_storage_*` span is created for them,
|
|
143
|
+
* mirroring how `cf_`-prefixed SQL tables are handled (see {@link durableObjectSqlSpanAllowlist}).
|
|
144
|
+
* If one of your own keys happens to use such a prefix, add it here to opt it back into
|
|
145
|
+
* instrumentation. Strings must match exactly, while regular expressions give you prefix/pattern
|
|
146
|
+
* matching.
|
|
147
|
+
*
|
|
148
|
+
* @default []
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* export default Sentry.withSentry(
|
|
152
|
+
* (env) => ({
|
|
153
|
+
* dsn: env.SENTRY_DSN,
|
|
154
|
+
* durableObjectStorageSpanAllowlist: ['cf_my_key', /^cf_reports_/],
|
|
155
|
+
* }),
|
|
156
|
+
* handler,
|
|
157
|
+
* );
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
durableObjectStorageSpanAllowlist?: Array<string | RegExp>;
|
|
135
161
|
/**
|
|
136
162
|
* @deprecated Use `enableRpcTracePropagation` instead. This option will be removed in a future major version.
|
|
137
163
|
*
|
|
@@ -145,6 +171,17 @@ interface BaseCloudflareOptions {
|
|
|
145
171
|
* @default false
|
|
146
172
|
*/
|
|
147
173
|
instrumentPrototypeMethods?: boolean | string[];
|
|
174
|
+
/**
|
|
175
|
+
* If you use Spotlight by Sentry during development, use
|
|
176
|
+
* this option to forward captured Sentry events to Spotlight.
|
|
177
|
+
*
|
|
178
|
+
* Either set it to true, or provide a specific Spotlight Sidecar URL.
|
|
179
|
+
*
|
|
180
|
+
* More details: https://spotlightjs.com/
|
|
181
|
+
*
|
|
182
|
+
* IMPORTANT: Only set this option to `true` while developing, not in production!
|
|
183
|
+
*/
|
|
184
|
+
spotlight?: boolean | string;
|
|
148
185
|
}
|
|
149
186
|
/**
|
|
150
187
|
* Configuration options for the Sentry Cloudflare SDK
|
|
@@ -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,
|
|
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,EAIL,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,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,qBAAqB,CAA6B;IAC1D,OAAO,CAAC,mBAAmB,CAA6B;IAExD;;;OAGG;gBACgB,OAAO,EAAE,uBAAuB;IAqDnD;;;;;;;;OAQG;IACU,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA2BtD;;;;;;;;OAQG;IACa,OAAO,IAAI,IAAI;IAkB/B,kBAAkB;cACC,kBAAkB,IAAI,IAAI;IAS7C;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAKpC;AAED,UAAU,qBAAqB;IAC7B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;;;;;;;OAUG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IAEpC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,6BAA6B,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAEvD;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,iCAAiC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IAE3D;;;;;;;;;;;OAWG;IACH,0BAA0B,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAAC;IAEhD;;;;;;;;;OASG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO,CAAC,0BAA0B,CAAC,EAAE,qBAAqB;IACnG,GAAG,CAAC,EAAE,sBAAsB,CAAC;CAC9B;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,5 +1,53 @@
|
|
|
1
1
|
import type { DurableObject } from 'cloudflare:workers';
|
|
2
2
|
import type { CloudflareOptions } from './client';
|
|
3
|
+
/**
|
|
4
|
+
* The instrumented context passed between the shared construction helpers.
|
|
5
|
+
*
|
|
6
|
+
* This is intentionally `any` rather than `ReturnType<typeof instrumentContext<DurableObjectState>>`.
|
|
7
|
+
* A concrete `DurableObjectState` here forces `tsc` to structurally relate its `storage: SqlStorage`
|
|
8
|
+
* graph against the `ExecutionContext | InstrumentedDurableObjectState` parameter of
|
|
9
|
+
* `wrapMethodWithSentry`, while the RPC-branded `DurableObject` from `cloudflare:workers` is also in
|
|
10
|
+
* scope. That union comparison explodes (1296×1296) and hangs the type build. The original inline
|
|
11
|
+
* implementation avoided this only incidentally, because `ctx` reached it as `any` through the Proxy
|
|
12
|
+
* `construct` trap. Keeping the shared context `any` preserves that behavior.
|
|
13
|
+
*/
|
|
14
|
+
type InstrumentedDurableObjectContext = any;
|
|
15
|
+
/**
|
|
16
|
+
* Constructs a Durable Object instance and instruments its built-in handler methods
|
|
17
|
+
* (`fetch`, `alarm`, `webSocketMessage`, `webSocketClose`, `webSocketError`).
|
|
18
|
+
*
|
|
19
|
+
* This is the shared construction path used by both {@link instrumentDurableObjectWithSentry}
|
|
20
|
+
* and {@link instrumentAgentWithSentry}. It intentionally does NOT apply the RPC prototype-method
|
|
21
|
+
* instrumentation — callers apply that last via {@link finalizeWithRpcInstrumentation}, after any
|
|
22
|
+
* additional per-instance instrumentation has been layered onto the returned object.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function constructInstrumentedDurableObject<E, T extends DurableObject<E>>(target: new (state: DurableObjectState, env: E) => T, ctx: DurableObjectState, env: E, newTarget: NewableFunction, optionsCallback: (env: E) => CloudflareOptions): {
|
|
27
|
+
obj: T;
|
|
28
|
+
options: CloudflareOptions;
|
|
29
|
+
context: InstrumentedDurableObjectContext;
|
|
30
|
+
frameworkManagedMethods: ReadonlySet<string>;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Adds trace propagation to a constructed Durable Object's RPC methods.
|
|
34
|
+
*
|
|
35
|
+
* RPC methods are wrapped on the prototype because Cloudflare dispatches them with the Durable
|
|
36
|
+
* Object instance as the receiver. This preserves native private-field access and keeps the methods
|
|
37
|
+
* visible to Cloudflare's RPC dispatcher. Built-in handlers, Agent handlers, and methods managed by
|
|
38
|
+
* another framework are left untouched.
|
|
39
|
+
*
|
|
40
|
+
* Call this after all per-instance instrumentation has been applied. If RPC trace propagation is
|
|
41
|
+
* disabled, the object is returned unchanged.
|
|
42
|
+
*
|
|
43
|
+
* @param obj The constructed Durable Object instance.
|
|
44
|
+
* @param options The resolved SDK options for this instance.
|
|
45
|
+
* @param context The instrumented execution context for this instance.
|
|
46
|
+
* @param excludedMethods Method names owned by another framework and therefore not safe to wrap.
|
|
47
|
+
* @returns The same Durable Object instance, with eligible prototype methods instrumented.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function finalizeWithRpcInstrumentation<T extends object>(obj: T, options: CloudflareOptions, context: InstrumentedDurableObjectContext, excludedMethods?: ReadonlySet<string>): T;
|
|
3
51
|
/**
|
|
4
52
|
* Instruments a Durable Object class to capture errors and performance data.
|
|
5
53
|
*
|
|
@@ -34,4 +82,46 @@ import type { CloudflareOptions } from './client';
|
|
|
34
82
|
* ```
|
|
35
83
|
*/
|
|
36
84
|
export declare function instrumentDurableObjectWithSentry<E, T extends DurableObject<E>, C extends new (state: DurableObjectState, env: E) => T>(optionsCallback: (env: E) => CloudflareOptions, DurableObjectClass: C): C;
|
|
85
|
+
/**
|
|
86
|
+
* Instruments a Cloudflare [`agents`](https://www.npmjs.com/package/agents) Agent class with Sentry.
|
|
87
|
+
*
|
|
88
|
+
* An `Agent` is a Durable Object under the hood, so this applies the same instrumentation as
|
|
89
|
+
* {@link instrumentDurableObjectWithSentry} (request transactions, `alarm`, WebSocket handlers, RPC
|
|
90
|
+
* trace propagation, SQL spans) and additionally captures Agent-specific telemetry via
|
|
91
|
+
* `instrumentCloudflareAgent`:
|
|
92
|
+
*
|
|
93
|
+
* - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
|
|
94
|
+
* - **Breadcrumbs** — for every Agent observability event (`rpc`, `state:update`, `connect`,
|
|
95
|
+
* `disconnect`, `schedule:*`, `queue:*`, `workflow:*`, `email:*`, `mcp:*`, ...).
|
|
96
|
+
*
|
|
97
|
+
* Cloudflare Workers cannot auto-instrument, so the Agent class must be wrapped manually.
|
|
98
|
+
*
|
|
99
|
+
* @param optionsCallback Function that returns the options for the SDK initialization.
|
|
100
|
+
* @param AgentClass The Agent class to instrument.
|
|
101
|
+
* @returns The instrumented Agent class.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { Agent, callable, routeAgentRequest } from 'agents';
|
|
106
|
+
* import * as Sentry from '@sentry/cloudflare';
|
|
107
|
+
*
|
|
108
|
+
* class MyAgentBase extends Agent<Env> {
|
|
109
|
+
* @callable()
|
|
110
|
+
* async greet(name: string): Promise<string> {
|
|
111
|
+
* return `Hello, ${name}!`;
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
*
|
|
115
|
+
* export const MyAgent = Sentry.instrumentAgentWithSentry(
|
|
116
|
+
* env => ({
|
|
117
|
+
* dsn: env.SENTRY_DSN,
|
|
118
|
+
* tracesSampleRate: 1.0,
|
|
119
|
+
* enableRpcTracePropagation: true,
|
|
120
|
+
* }),
|
|
121
|
+
* MyAgentBase,
|
|
122
|
+
* );
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function instrumentAgentWithSentry<E, T extends DurableObject<E>, C extends new (state: DurableObjectState, env: E) => T>(optionsCallback: (env: E) => CloudflareOptions, AgentClass: C): C;
|
|
126
|
+
export {};
|
|
37
127
|
//# sourceMappingURL=durableobject.d.ts.map
|
|
@@ -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,oB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,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,UAAU,EAAE,CAAC,GAAG,CAAC,CAoBlE"}
|
package/build/types/flush.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type FlushLock = {
|
|
|
19
19
|
*
|
|
20
20
|
* By using the original waitUntil for flush operations, we bypass this issue.
|
|
21
21
|
*/
|
|
22
|
-
export declare function getOriginalWaitUntil(context: ExecutionContextCompat): ExecutionContext['waitUntil']
|
|
22
|
+
export declare function getOriginalWaitUntil(context: ExecutionContextCompat): ExecutionContext['waitUntil'];
|
|
23
23
|
/**
|
|
24
24
|
* Enhances the given execution context by wrapping its `waitUntil` method with a proxy
|
|
25
25
|
* to monitor pending tasks, and provides a flusher function to ensure all tasks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flush.d.ts","sourceRoot":"","sources":["../../src/flush.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC,CAAC;AAcF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"flush.d.ts","sourceRoot":"","sources":["../../src/flush.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAEjE,KAAK,SAAS,GAAG;IACf,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC,CAAC;AAcF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,sBAAsB,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAKnG;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,SAAS,CA8BxE;AAoCD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/F"}
|
package/build/types/index.d.ts
CHANGED
|
@@ -3,13 +3,14 @@ export type { CloudflareOptions } from './client';
|
|
|
3
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, setAttribute, setAttributes, setUser, setConversationId, getSpanStatusFromHttpCode, setHttpStatus, withScope, withIsolationScope, captureCheckIn, withMonitor, setMeasurement, getActiveSpan, getRootSpan, getTraceData, getTraceMetaTags, startSpan, startInactiveSpan, startSpanManual, startNewTrace, bindScopeToEmitter, 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, instrumentStateGraph, instrumentLangGraph, instrumentCreateReactAgent, } from '@sentry/core';
|
|
4
4
|
export { withSentry } from './withSentry';
|
|
5
5
|
export { defineCloudflareOptions } from './defineCloudflareOptions';
|
|
6
|
-
export { instrumentDurableObjectWithSentry } from './durableobject';
|
|
6
|
+
export { instrumentAgentWithSentry, instrumentDurableObjectWithSentry } from './durableobject';
|
|
7
7
|
export { sentryPagesPlugin } from './pages-plugin';
|
|
8
8
|
export { wrapRequestHandler } from './request';
|
|
9
9
|
export { CloudflareClient } from './client';
|
|
10
10
|
export { getDefaultIntegrations } from './sdk';
|
|
11
11
|
export { httpServerIntegration } from './integrations/httpServer';
|
|
12
12
|
export { fetchIntegration } from './integrations/fetch';
|
|
13
|
+
export { spotlightIntegration } from './integrations/spotlight';
|
|
13
14
|
export { vercelAIIntegration } from './integrations/tracing/vercelai';
|
|
14
15
|
export { honoIntegration } from './integrations/hono';
|
|
15
16
|
export { instrumentD1WithSentry } from './instrumentations/worker/instrumentD1';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,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,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,8BAA8B,EAC9B,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EAEpB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;
|
|
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,YAAY,EACZ,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,yBAAyB,EACzB,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,WAAW,EAC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EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAEhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,OAAO,EAAE,wCAAwC,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instruments an instance of a Cloudflare [`agents`](https://www.npmjs.com/package/agents) `Agent`
|
|
3
|
+
* with Sentry, adding telemetry that is specific to the Agent's runtime behavior:
|
|
4
|
+
*
|
|
5
|
+
* - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.
|
|
6
|
+
* - **Conversation correlation** — sets the conversation id on the scope for each unit of agent
|
|
7
|
+
* work — chat turn, callable RPC call, or HTTP request — so `gen_ai` spans created within it are
|
|
8
|
+
* correlated, for chat and plain agents alike. The id is minted once per agent instance and
|
|
9
|
+
* rotated when the chat is cleared (the `message:clear` observability event); it is persisted to
|
|
10
|
+
* Durable Object storage so it survives hibernation.
|
|
11
|
+
*
|
|
12
|
+
* It only hooks the `agents` package internals and uses Sentry's tracing primitives. On Cloudflare
|
|
13
|
+
* Workers, prefer `instrumentAgentWithSentry`, which additionally instruments the Durable Object
|
|
14
|
+
* handlers and initializes the SDK; that function calls this one internally.
|
|
15
|
+
*
|
|
16
|
+
* The hooks replace own-properties on the instance and defer to the original implementation, so
|
|
17
|
+
* they compose with any other instrumentation applied to the same instance.
|
|
18
|
+
*
|
|
19
|
+
* @param agent The `agents` `Agent` instance to instrument.
|
|
20
|
+
* @returns The same instance, instrumented.
|
|
21
|
+
*
|
|
22
|
+
* @internal Use `instrumentAgentWithSentry` instead — this is called internally by it.
|
|
23
|
+
*/
|
|
24
|
+
export declare function instrumentCloudflareAgent<T extends object>(agent: T): T;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/agents/index.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAQvE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type AgentInternals } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the Agent's `onMessage` handler to create a span for each `@callable()` RPC invocation.
|
|
4
|
+
* RPC requests arrive as WebSocket messages, so this span nests under the active transaction for
|
|
5
|
+
* the WebSocket message (on Cloudflare, the instrumented Durable Object `webSocketMessage` hook).
|
|
6
|
+
*
|
|
7
|
+
* Also sets the conversation id on the scope for the duration of the call: callable methods are the
|
|
8
|
+
* unit of work for plain (non-chat) agents, which run LLM calls just like chat turns do. It is
|
|
9
|
+
* awaited so the id is on the scope before the method body creates any span; the `agents`
|
|
10
|
+
* `onMessage` own property this wraps is already `async`, so the promise return is nothing new to
|
|
11
|
+
* the WebSocket dispatch upstream.
|
|
12
|
+
*/
|
|
13
|
+
export declare function instrumentAgentCallableRpc(obj: AgentInternals): void;
|
|
14
|
+
//# sourceMappingURL=instrumentAgentCallableRpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentAgentCallableRpc.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/agents/instrumentAgentCallableRpc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,cAAc,EAA8C,MAAM,SAAS,CAAC;AAE7G;;;;;;;;;;GAUG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CA+BpE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AgentInternals } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Correlates the AI spans of an HTTP-driven agent turn with a conversation id on the active scope.
|
|
4
|
+
*
|
|
5
|
+
* `onRequest` is the third unit of agent work, alongside chat turns and `@callable()` RPC: the
|
|
6
|
+
* `agents` router sends every non-WebSocket request to it, which is how REST endpoints and webhooks
|
|
7
|
+
* reach an agent.
|
|
8
|
+
*
|
|
9
|
+
* `agents` installs `onRequest` as an own property in the `Agent` constructor (as it does
|
|
10
|
+
* `onMessage`), and we instrument after construction, so wrapping the own property is what the
|
|
11
|
+
* router ends up calling. That own property is already `async`, and partyserver's `fetch` awaits it,
|
|
12
|
+
* so returning a promise from this wrapper — to get the conversation id onto the scope before the
|
|
13
|
+
* request handler creates any span — keeps the existing contract.
|
|
14
|
+
*/
|
|
15
|
+
export declare function instrumentAgentRequestConversation(obj: AgentInternals): void;
|
|
16
|
+
//# sourceMappingURL=instrumentAgentRequestConversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentAgentRequestConversation.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/agents/instrumentAgentRequestConversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAA0B,MAAM,SAAS,CAAC;AAEtE;;;;;;;;;;;;GAYG;AACH,wBAAgB,kCAAkC,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAc5E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AgentInternals } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* For chat agents (`AIChatAgent` from `@cloudflare/ai-chat`), correlates each chat turn's AI spans
|
|
4
|
+
* with a conversation id on the active scope.
|
|
5
|
+
*
|
|
6
|
+
* In the Agents model one agent instance is one long-lived conversation, so the conversation id is
|
|
7
|
+
* minted once per instance and persisted to Durable Object storage, which is what carries it across
|
|
8
|
+
* hibernation (that destroys the in-memory instance). When the user clears the chat, they expect a
|
|
9
|
+
* fresh conversation — but recreating the Durable Object for that would also drop the MCP/OAuth
|
|
10
|
+
* state stored per instance (GitHub/Sentry sign-in). To get a fresh conversation id *without*
|
|
11
|
+
* losing that state, we rotate the persisted id when the SDK reports a cleared chat.
|
|
12
|
+
*
|
|
13
|
+
* The id itself is not attached to spans here — `setAgentConversationId` resolves it, and the SDK's
|
|
14
|
+
* `conversationIdIntegration` picks it off the scope at `spanStart` to stamp
|
|
15
|
+
* `gen_ai.conversation.id` onto the AI spans created inside the turn (e.g. by the Workers AI
|
|
16
|
+
* instrumentation), which correlates a turn's model and tool calls.
|
|
17
|
+
*
|
|
18
|
+
* Plain (non-chat) `Agent`s do not define `onChatMessage`, so they are skipped here — their unit
|
|
19
|
+
* of work is the callable RPC method, where `instrumentAgentCallableRpc` sets the conversation id
|
|
20
|
+
* instead.
|
|
21
|
+
*/
|
|
22
|
+
export declare function instrumentChatAgentConversation(obj: AgentInternals): void;
|
|
23
|
+
//# sourceMappingURL=instrumentChatAgentConversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentChatAgentConversation.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/agents/instrumentChatAgentConversation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,cAAc,EAAoD,MAAM,SAAS,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAgCzE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { InstrumentedDurableObjectState } from '../../wrapMethodWithSentry';
|
|
2
|
+
export declare const AGENT_SPAN_ORIGIN = "auto.faas.cloudflare.agents";
|
|
3
|
+
/** DO storage key under which the conversation id is persisted so it survives hibernation. */
|
|
4
|
+
export declare const AGENT_CONVERSATION_ID_STORAGE_KEY = "__SENTRY_AGENT_CONVERSATION_ID__";
|
|
5
|
+
/**
|
|
6
|
+
* Instance keys for our conversation-id bookkeeping, keyed by symbol so the state stays invisible
|
|
7
|
+
* to anything enumerating the user-owned agent instance (`Object.keys`, `JSON.stringify`, spread).
|
|
8
|
+
* Exported because the exported `AgentInternals` interface references them.
|
|
9
|
+
*/
|
|
10
|
+
export declare const AGENT_CONVERSATION_ID_SYMBOL: unique symbol;
|
|
11
|
+
export declare const AGENT_APPLIED_CONVERSATION_ID_SYMBOL: unique symbol;
|
|
12
|
+
/**
|
|
13
|
+
* The subset of the `agents` `Agent` instance internals that we instrument. These are runtime
|
|
14
|
+
* implementation details of the `agents` package (v0.13.x) rather than part of its public type
|
|
15
|
+
* surface, so every access is guarded and wrapping degrades gracefully if a name changes upstream.
|
|
16
|
+
*/
|
|
17
|
+
export interface AgentInternals {
|
|
18
|
+
/** Central choke-point through which all `agents:*` observability events are published. */
|
|
19
|
+
_emit?: (type: string, payload?: Record<string, unknown>) => void;
|
|
20
|
+
/** WebSocket message handler; dispatches `@callable()` RPC requests. */
|
|
21
|
+
onMessage?: (...args: unknown[]) => unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Chat-turn handler. Only `AIChatAgent` (from `@cloudflare/ai-chat`) defines this; a plain `Agent`
|
|
24
|
+
* does not, so its presence discriminates a chat agent.
|
|
25
|
+
*/
|
|
26
|
+
onChatMessage?: (...args: unknown[]) => unknown;
|
|
27
|
+
/** HTTP request handler; the router sends every non-WebSocket request here. */
|
|
28
|
+
onRequest?: (...args: unknown[]) => unknown;
|
|
29
|
+
/** The user's Agent class (used by the SDK for the observability event `agent` field). */
|
|
30
|
+
_ParentClass?: {
|
|
31
|
+
name?: string;
|
|
32
|
+
};
|
|
33
|
+
/** The Agent instance name, reported as the `cloudflare.agent.name` span attribute. */
|
|
34
|
+
name?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The Durable Object state of the instance. Present on every real Agent; guarded like the other
|
|
37
|
+
* internals so partially-mocked instances keep working.
|
|
38
|
+
*/
|
|
39
|
+
ctx?: InstrumentedDurableObjectState;
|
|
40
|
+
/**
|
|
41
|
+
* The current conversation id for this agent instance. It is cached in memory after being loaded
|
|
42
|
+
* from Durable Object storage and updated when the conversation rotates. `undefined` means storage
|
|
43
|
+
* has not been read yet.
|
|
44
|
+
*/
|
|
45
|
+
[AGENT_CONVERSATION_ID_SYMBOL]?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The conversation id this instrumentation most recently applied to the isolation scope. It lets
|
|
48
|
+
* subsequent units of work distinguish an SDK-applied id, which may be replaced after rotation,
|
|
49
|
+
* from an id explicitly set by the user, which must be preserved.
|
|
50
|
+
*/
|
|
51
|
+
[AGENT_APPLIED_CONVERSATION_ID_SYMBOL]?: string;
|
|
52
|
+
}
|
|
53
|
+
/** Reads best-effort agent identity attributes from the instance, tolerating missing internals. */
|
|
54
|
+
export declare function getAgentAttributes(instance: AgentInternals): Record<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Persists the conversation id to Durable Object storage, so it survives hibernation, and updates
|
|
57
|
+
* the in-memory cache synchronously so the current wake is immediately consistent even if the
|
|
58
|
+
* write fails. Uses the async storage API, which exists on KV- and SQLite-backed DOs alike.
|
|
59
|
+
* The write is fire-and-forget: DO storage writes are tracked by the runtime and land without
|
|
60
|
+
* awaiting (`waitUntil` is a no-op in Durable Objects), and the catch keeps a rejection from
|
|
61
|
+
* surfacing as unhandled — a failed write just means the next wake starts a new conversation,
|
|
62
|
+
* which must never throw into user code. Uses the original uninstrumented storage so internal
|
|
63
|
+
* bookkeeping doesn't create spans.
|
|
64
|
+
*/
|
|
65
|
+
export declare function storeAgentConversationId(instance: AgentInternals, conversationId: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the agent instance's conversation id on the active scope for the duration of the
|
|
68
|
+
* surrounding unit of work (chat turn, callable RPC call, HTTP request). In the Agents model one
|
|
69
|
+
* instance is one long-lived conversation, so the id is minted once per instance and persisted to
|
|
70
|
+
* DO storage — for chat and plain agents alike, since plain agents run LLM calls too (e.g. inside
|
|
71
|
+
* `@callable()` methods). The instance `name` is deliberately not used: it is caller-chosen and can
|
|
72
|
+
* be a stable, guessable, or shared value, whereas a conversation id should identify exactly one
|
|
73
|
+
* conversation. Clearing the chat rotates it (see `storeAgentConversationId`) so subsequent LLM
|
|
74
|
+
* calls group under the fresh conversation.
|
|
75
|
+
*
|
|
76
|
+
* Every handler wrapper awaits this before invoking the original, so the id is on the scope before
|
|
77
|
+
* the unit of work — and any `gen_ai` span it creates — starts. Only the first unit of work per wake
|
|
78
|
+
* pays the storage read; the rest resolve from the in-memory cache. Awaiting is safe on all three
|
|
79
|
+
* paths because the `agents` `Agent` constructor already replaces `onMessage` and `onRequest` with
|
|
80
|
+
* `async` wrappers of its own, and `onChatMessage` is async by contract, so every caller upstream
|
|
81
|
+
* already handles a promise.
|
|
82
|
+
*
|
|
83
|
+
* An id the user set explicitly outranks this inferred one, in either order: a `setConversationId()`
|
|
84
|
+
* call that already happened is detected here and left alone, and one made inside the handler lands
|
|
85
|
+
* on the same scope afterwards and therefore wins. That is why the write targets the isolation scope
|
|
86
|
+
* — it is the scope the public `Sentry.setConversationId()` writes to, and `conversationIdIntegration`
|
|
87
|
+
* prefers the current scope over it, so writing there would make a user's call unoverridable.
|
|
88
|
+
*
|
|
89
|
+
* `conversationIdIntegration` reads the id off the scope at `spanStart` and stamps
|
|
90
|
+
* `gen_ai.conversation.id` onto AI spans created within the unit of work, correlating its model and
|
|
91
|
+
* tool calls.
|
|
92
|
+
*/
|
|
93
|
+
export declare function setAgentConversationId(instance: AgentInternals): Promise<void>;
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/instrumentations/agents/types.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAMjF,eAAO,MAAM,iBAAiB,gCAAgC,CAAC;AAE/D,8FAA8F;AAC9F,eAAO,MAAM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E,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAapF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentDurableObjectStorage.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentDurableObjectStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA6B,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumentDurableObjectStorage.d.ts","sourceRoot":"","sources":["../../../src/instrumentations/instrumentDurableObjectStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAA6B,MAAM,2BAA2B,CAAC;AAYjG,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,CAiFtB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type SpotlightConnectionOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Set this if the Spotlight Sidecar is not running on localhost:8969.
|
|
4
|
+
* By default, the URL is set to http://localhost:8969/stream
|
|
5
|
+
*/
|
|
6
|
+
sidecarUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const INTEGRATION_NAME: "Spotlight";
|
|
9
|
+
/**
|
|
10
|
+
* Use this integration to send errors and transactions to Spotlight.
|
|
11
|
+
*
|
|
12
|
+
* Learn more about spotlight at https://spotlightjs.com
|
|
13
|
+
*
|
|
14
|
+
* Important: This integration is intended for local development only.
|
|
15
|
+
* Each forwarded envelope counts as a Worker subrequest (50 free / 1000 paid
|
|
16
|
+
* per invocation), so it should not be enabled in production.
|
|
17
|
+
*/
|
|
18
|
+
export declare const spotlightIntegration: (options?: Partial<SpotlightConnectionOptions> | undefined) => import("@sentry/core").Integration & {
|
|
19
|
+
name: "Spotlight";
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=spotlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spotlight.d.ts","sourceRoot":"","sources":["../../../src/integrations/spotlight.ts"],"names":[],"mappings":"AAIA,KAAK,0BAA0B,GAAG;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAG,WAAoB,CAAC;AAcrD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB;;CAA2C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAyBlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,iBAAiB,YAAK,EAAE,GAAG,EAAE,OAAO,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/options.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAyBlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,iBAAiB,YAAK,EAAE,GAAG,EAAE,OAAO,GAAG,iBAAiB,CAgCpG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAc3F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAYjE,UAAU,4BAA4B;IACpC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IACxF,OAAO,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC5C;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,4BAA4B,EAC5C,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAC5D,OAAO,CAAC,QAAQ,CAAC,CAsJnB"}
|
package/build/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAchD,OAAO,KAAK,EAA2B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAchD,OAAO,KAAK,EAA2B,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AA2B5C,2DAA2D;AAC3D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,EAAE,CA8BhF;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,SAAS,CAoC7E"}
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
*
|
|
13
13
|
* The check operates on the query summary produced by `getSqlQuerySummary` (`{operation} {table} ...`,
|
|
14
14
|
* the same value used as the span name), so table targets are already isolated from the rest of the
|
|
15
|
-
* query.
|
|
15
|
+
* query. The one exception is `CREATE INDEX`: its summary carries the index name, not the indexed
|
|
16
|
+
* table (upstream OTel convention), so the `cf_` target only appears in the ON clause of the full
|
|
17
|
+
* statement, which `queryText` is needed for.
|
|
16
18
|
*/
|
|
17
|
-
export declare function targetsCloudflareInternalTable(querySummary: string | undefined, allowlist?: Array<string | RegExp
|
|
19
|
+
export declare function targetsCloudflareInternalTable(querySummary: string | undefined, allowlist?: Array<string | RegExp>, queryText?: string): boolean;
|
|
18
20
|
//# sourceMappingURL=internalSqlQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalSqlQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/internalSqlQuery.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"internalSqlQuery.d.ts","sourceRoot":"","sources":["../../../src/utils/internalSqlQuery.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,8BAA8B,CAC5C,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,EAClC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAaT"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloudflare frameworks that build on Durable Objects (`agents`, `partyserver`, ...) also manage
|
|
3
|
+
* their own internal KV entries alongside their internal SQLite tables, namespaced with a reserved
|
|
4
|
+
* prefix — e.g. `cf_agents_state`, `cf_agents_mcp_servers`, `__ps_name`. Reads/writes of these
|
|
5
|
+
* (message persistence, MCP connection bookkeeping, name hydration) are framework implementation
|
|
6
|
+
* details that otherwise flood traces with dozens of zero-signal `durable_object_storage_*` spans
|
|
7
|
+
* per request, so we match the reserved prefixes rather than an enumerated list. This mirrors the
|
|
8
|
+
* `cf_` convention used for internal SQL tables (see `targetsCloudflareInternalTable`).
|
|
9
|
+
*
|
|
10
|
+
* The prefixes are a reserved convention for framework-managed entries, so user keys should not use
|
|
11
|
+
* them. In case a user key does collide, the `durableObjectStorageSpanAllowlist` option lets them
|
|
12
|
+
* opt those keys back into instrumentation.
|
|
13
|
+
*/
|
|
14
|
+
export declare function targetsCloudflareInternalKey(key: string | undefined, allowlist?: Array<string | RegExp>): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Extracts the KV keys a Durable Object storage call targets, so the caller can decide whether the
|
|
17
|
+
* operation only touches framework-internal entries. Returns `undefined` when the keys can't be
|
|
18
|
+
* determined from the arguments (e.g. `list()` without a prefix), in which case the call is treated
|
|
19
|
+
* as user work and stays instrumented.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getStorageKeys(methodName: string, args: unknown[]): string[] | undefined;
|
|
22
|
+
//# sourceMappingURL=internalStorageKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internalStorageKey.d.ts","sourceRoot":"","sources":["../../../src/utils/internalStorageKey.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,OAAO,CAsBjH;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,GAAG,SAAS,CAgCxF"}
|