@sentry/cloudflare 10.70.0 → 11.0.0-alpha.1
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/README.md +3 -7
- package/build/cjs/{sdk.js → dev/baseSdk.js} +27 -17
- package/build/cjs/dev/baseSdk.js.map +1 -0
- package/build/cjs/dev/client.js.map +1 -0
- package/build/cjs/dev/debug-build.js.map +1 -0
- package/build/cjs/dev/defineCloudflareOptions.js.map +1 -0
- package/build/cjs/{durableobject.js → dev/durableobject.js} +21 -20
- package/build/cjs/dev/durableobject.js.map +1 -0
- package/build/cjs/dev/flush.js.map +1 -0
- package/build/cjs/{index.js → dev/index.js} +16 -17
- package/build/cjs/{index.js.map → dev/index.js.map} +1 -1
- package/build/cjs/dev/instrument.js.map +1 -0
- package/build/cjs/dev/instrumentations/agents/index.js.map +1 -0
- package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/agents/types.js +4 -4
- package/build/cjs/dev/instrumentations/agents/types.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +3 -3
- package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +0 -4
- package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
- package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
- package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +9 -3
- package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +3 -2
- package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
- package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/cjs/{integrations → dev/integrations}/fetch.js +1 -1
- package/build/cjs/dev/integrations/fetch.js.map +1 -0
- package/build/cjs/{integrations → dev/integrations}/httpServer.js +5 -4
- package/build/cjs/dev/integrations/httpServer.js.map +1 -0
- package/build/cjs/dev/integrations/spotlight.js.map +1 -0
- package/build/cjs/{nodejs_compat → dev}/integrations/tracing/vercelai.js +6 -6
- package/build/cjs/dev/integrations/tracing/vercelai.js.map +1 -0
- package/build/cjs/dev/opentelemetry/tracer.js.map +1 -0
- package/build/cjs/{options.js → dev/options.js} +8 -0
- package/build/cjs/dev/options.js.map +1 -0
- package/build/cjs/{pages-plugin.js → dev/pages-plugin.js} +8 -3
- package/build/cjs/dev/pages-plugin.js.map +1 -0
- package/build/cjs/{request.js → dev/request.js} +20 -10
- package/build/cjs/dev/request.js.map +1 -0
- package/build/cjs/dev/scope-utils.js.map +1 -0
- package/build/cjs/dev/sdk.js +19 -0
- package/build/cjs/dev/sdk.js.map +1 -0
- package/build/cjs/dev/transport.js.map +1 -0
- package/build/cjs/{utils → dev/utils}/instrumentContext.js +8 -13
- package/build/cjs/dev/utils/instrumentContext.js.map +1 -0
- package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -0
- package/build/cjs/dev/utils/internalStorageKey.js.map +1 -0
- package/build/cjs/dev/utils/invocationScope.js.map +1 -0
- package/build/cjs/dev/utils/isBinding.js.map +1 -0
- package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -0
- package/build/cjs/dev/utils/rpcMeta.js.map +1 -0
- package/build/cjs/dev/utils/streaming.js.map +1 -0
- package/build/cjs/dev/utils/traceLinks.js.map +1 -0
- package/build/cjs/dev/vendor/stacktrace.js.map +1 -0
- package/build/cjs/dev/vite/agentClass.js.map +1 -0
- package/build/cjs/dev/vite/autoInstrument.js.map +1 -0
- package/build/cjs/{vite → dev/vite}/index.js +4 -2
- package/build/cjs/dev/vite/index.js.map +1 -0
- package/build/cjs/dev/vite/instrumentFile.js.map +1 -0
- package/build/cjs/dev/vite/moduleShape.js.map +1 -0
- package/build/cjs/dev/vite/transform.js.map +1 -0
- package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -0
- package/build/cjs/dev/vite/wranglerConfig.js.map +1 -0
- package/build/cjs/{withSentry.js → dev/withSentry.js} +2 -19
- package/build/cjs/dev/withSentry.js.map +1 -0
- package/build/cjs/{workflows.js → dev/workflows.js} +8 -3
- package/build/cjs/dev/workflows.js.map +1 -0
- package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -0
- package/build/cjs/prod/baseSdk.js +73 -0
- package/build/cjs/prod/baseSdk.js.map +1 -0
- package/build/cjs/prod/client.js +122 -0
- package/build/cjs/prod/client.js.map +1 -0
- package/build/cjs/prod/debug-build.js +6 -0
- package/build/cjs/prod/debug-build.js.map +1 -0
- package/build/cjs/prod/defineCloudflareOptions.js +11 -0
- package/build/cjs/prod/defineCloudflareOptions.js.map +1 -0
- package/build/cjs/prod/durableobject.js +234 -0
- package/build/cjs/prod/durableobject.js.map +1 -0
- package/build/cjs/prod/flush.js +87 -0
- package/build/cjs/prod/flush.js.map +1 -0
- package/build/cjs/{nodejs_compat → prod}/index.js +34 -37
- package/build/cjs/{nodejs_compat → prod}/index.js.map +1 -1
- package/build/cjs/prod/instrument.js +52 -0
- package/build/cjs/prod/instrument.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/index.js +16 -0
- package/build/cjs/prod/instrumentations/agents/index.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +52 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +19 -0
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +31 -0
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/cjs/prod/instrumentations/agents/types.js +77 -0
- package/build/cjs/prod/instrumentations/agents/types.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +41 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +72 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +40 -0
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +42 -0
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +139 -0
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js +161 -0
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +90 -0
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +54 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +24 -0
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +82 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +80 -0
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js +124 -0
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js +29 -0
- package/build/cjs/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +78 -0
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js +60 -0
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/cjs/prod/integrations/fetch.js +119 -0
- package/build/cjs/prod/integrations/fetch.js.map +1 -0
- package/build/cjs/prod/integrations/httpServer.js +36 -0
- package/build/cjs/prod/integrations/httpServer.js.map +1 -0
- package/build/cjs/prod/integrations/spotlight.js +64 -0
- package/build/cjs/prod/integrations/spotlight.js.map +1 -0
- package/build/cjs/{integrations → prod/integrations}/tracing/vercelai.js +5 -5
- package/build/cjs/prod/integrations/tracing/vercelai.js.map +1 -0
- package/build/cjs/prod/opentelemetry/tracer.js +49 -0
- package/build/cjs/prod/opentelemetry/tracer.js.map +1 -0
- package/build/cjs/prod/options.js +33 -0
- package/build/cjs/prod/options.js.map +1 -0
- package/build/cjs/prod/pages-plugin.js +24 -0
- package/build/cjs/prod/pages-plugin.js.map +1 -0
- package/build/cjs/prod/request.js +132 -0
- package/build/cjs/prod/request.js.map +1 -0
- package/build/cjs/prod/scope-utils.js +22 -0
- package/build/cjs/prod/scope-utils.js.map +1 -0
- package/build/cjs/prod/sdk.js +19 -0
- package/build/cjs/prod/sdk.js.map +1 -0
- package/build/cjs/prod/transport.js +75 -0
- package/build/cjs/prod/transport.js.map +1 -0
- package/build/cjs/prod/utils/instrumentContext.js +63 -0
- package/build/cjs/prod/utils/instrumentContext.js.map +1 -0
- package/build/cjs/prod/utils/internalSqlQuery.js +25 -0
- package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -0
- package/build/cjs/prod/utils/internalStorageKey.js +44 -0
- package/build/cjs/prod/utils/internalStorageKey.js.map +1 -0
- package/build/cjs/prod/utils/invocationScope.js +12 -0
- package/build/cjs/prod/utils/invocationScope.js.map +1 -0
- package/build/cjs/prod/utils/isBinding.js +37 -0
- package/build/cjs/prod/utils/isBinding.js.map +1 -0
- package/build/cjs/prod/utils/isCloudflareClass.js +23 -0
- package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -0
- package/build/cjs/prod/utils/rpcMeta.js +39 -0
- package/build/cjs/prod/utils/rpcMeta.js.map +1 -0
- package/build/cjs/prod/utils/streaming.js +16 -0
- package/build/cjs/prod/utils/streaming.js.map +1 -0
- package/build/cjs/prod/utils/traceLinks.js +54 -0
- package/build/cjs/prod/utils/traceLinks.js.map +1 -0
- package/build/cjs/prod/vendor/stacktrace.js +28 -0
- package/build/cjs/prod/vendor/stacktrace.js.map +1 -0
- package/build/cjs/prod/vite/agentClass.js +114 -0
- package/build/cjs/prod/vite/agentClass.js.map +1 -0
- package/build/cjs/prod/vite/autoInstrument.js +94 -0
- package/build/cjs/prod/vite/autoInstrument.js.map +1 -0
- package/build/cjs/prod/vite/index.js +16 -0
- package/build/cjs/prod/vite/index.js.map +1 -0
- package/build/cjs/prod/vite/instrumentFile.js +31 -0
- package/build/cjs/prod/vite/instrumentFile.js.map +1 -0
- package/build/cjs/prod/vite/moduleShape.js +231 -0
- package/build/cjs/prod/vite/moduleShape.js.map +1 -0
- package/build/cjs/prod/vite/transform.js +149 -0
- package/build/cjs/prod/vite/transform.js.map +1 -0
- package/build/cjs/prod/vite/workerEntrypoint.js +66 -0
- package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -0
- package/build/cjs/prod/vite/wranglerConfig.js +54 -0
- package/build/cjs/prod/vite/wranglerConfig.js.map +1 -0
- package/build/cjs/prod/withSentry.js +29 -0
- package/build/cjs/prod/withSentry.js.map +1 -0
- package/build/cjs/prod/workflows.js +139 -0
- package/build/cjs/prod/workflows.js.map +1 -0
- package/build/cjs/prod/wrapMethodWithSentry.js +134 -0
- package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -0
- package/build/esm/{sdk.js → dev/baseSdk.js} +26 -17
- package/build/esm/dev/baseSdk.js.map +1 -0
- package/build/esm/dev/client.js.map +1 -0
- package/build/esm/dev/debug-build.js.map +1 -0
- package/build/esm/dev/defineCloudflareOptions.js.map +1 -0
- package/build/esm/{durableobject.js → dev/durableobject.js} +21 -20
- package/build/esm/dev/durableobject.js.map +1 -0
- package/build/esm/dev/flush.js.map +1 -0
- package/build/esm/dev/index.js +15 -0
- package/build/esm/{index.js.map → dev/index.js.map} +1 -1
- package/build/esm/dev/instrument.js.map +1 -0
- package/build/esm/dev/instrumentations/agents/index.js.map +1 -0
- package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/agents/types.js +2 -2
- package/build/esm/dev/instrumentations/agents/types.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/instrumentWorkerEntrypoint.js +2 -2
- package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentD1.js +1 -4
- package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEmail.js +3 -1
- package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentEnv.js +3 -4
- package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetch.js +10 -4
- package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueue.js +4 -3
- package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentScheduled.js +3 -1
- package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/esm/{integrations → dev/integrations}/fetch.js +1 -1
- package/build/esm/dev/integrations/fetch.js.map +1 -0
- package/build/esm/{integrations → dev/integrations}/httpServer.js +5 -4
- package/build/esm/dev/integrations/httpServer.js.map +1 -0
- package/build/esm/dev/integrations/spotlight.js.map +1 -0
- package/build/esm/{integrations → dev/integrations}/tracing/vercelai.js +5 -5
- package/build/esm/dev/integrations/tracing/vercelai.js.map +1 -0
- package/build/esm/dev/opentelemetry/tracer.js.map +1 -0
- package/build/esm/{options.js → dev/options.js} +8 -0
- package/build/esm/dev/options.js.map +1 -0
- package/build/esm/dev/package.json +1 -0
- package/build/esm/{pages-plugin.js → dev/pages-plugin.js} +8 -3
- package/build/esm/dev/pages-plugin.js.map +1 -0
- package/build/esm/{request.js → dev/request.js} +21 -12
- package/build/esm/dev/request.js.map +1 -0
- package/build/esm/dev/scope-utils.js.map +1 -0
- package/build/esm/dev/sdk.js +16 -0
- package/build/esm/dev/sdk.js.map +1 -0
- package/build/esm/dev/transport.js.map +1 -0
- package/build/esm/{utils → dev/utils}/instrumentContext.js +8 -13
- package/build/esm/dev/utils/instrumentContext.js.map +1 -0
- package/build/esm/dev/utils/internalSqlQuery.js.map +1 -0
- package/build/esm/dev/utils/internalStorageKey.js.map +1 -0
- package/build/esm/dev/utils/invocationScope.js.map +1 -0
- package/build/esm/dev/utils/isBinding.js.map +1 -0
- package/build/esm/dev/utils/isCloudflareClass.js.map +1 -0
- package/build/esm/dev/utils/rpcMeta.js.map +1 -0
- package/build/esm/dev/utils/streaming.js.map +1 -0
- package/build/esm/{utils → dev/utils}/traceLinks.js +1 -1
- package/build/esm/dev/utils/traceLinks.js.map +1 -0
- package/build/esm/dev/vendor/stacktrace.js.map +1 -0
- package/build/esm/dev/vite/agentClass.js.map +1 -0
- package/build/esm/dev/vite/autoInstrument.js.map +1 -0
- package/build/esm/{vite → dev/vite}/index.js +4 -2
- package/build/esm/dev/vite/index.js.map +1 -0
- package/build/esm/dev/vite/instrumentFile.js.map +1 -0
- package/build/esm/dev/vite/moduleShape.js.map +1 -0
- package/build/esm/dev/vite/transform.js.map +1 -0
- package/build/esm/dev/vite/workerEntrypoint.js.map +1 -0
- package/build/esm/dev/vite/wranglerConfig.js.map +1 -0
- package/build/esm/{withSentry.js → dev/withSentry.js} +1 -18
- package/build/esm/dev/withSentry.js.map +1 -0
- package/build/esm/{workflows.js → dev/workflows.js} +7 -2
- package/build/esm/dev/workflows.js.map +1 -0
- package/build/esm/dev/wrapMethodWithSentry.js.map +1 -0
- package/build/esm/prod/baseSdk.js +69 -0
- package/build/esm/prod/baseSdk.js.map +1 -0
- package/build/esm/prod/client.js +120 -0
- package/build/esm/prod/client.js.map +1 -0
- package/build/esm/prod/debug-build.js +4 -0
- package/build/esm/prod/debug-build.js.map +1 -0
- package/build/esm/prod/defineCloudflareOptions.js +9 -0
- package/build/esm/prod/defineCloudflareOptions.js.map +1 -0
- package/build/esm/prod/durableobject.js +229 -0
- package/build/esm/prod/durableobject.js.map +1 -0
- package/build/esm/prod/flush.js +83 -0
- package/build/esm/prod/flush.js.map +1 -0
- package/build/esm/prod/index.js +15 -0
- package/build/esm/{nodejs_compat → prod}/index.js.map +1 -1
- package/build/esm/prod/instrument.js +48 -0
- package/build/esm/prod/instrument.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/index.js +14 -0
- package/build/esm/prod/instrumentations/agents/index.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +50 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +17 -0
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +29 -0
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -0
- package/build/esm/prod/instrumentations/agents/types.js +69 -0
- package/build/esm/prod/instrumentations/agents/types.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +38 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +38 -0
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js +40 -0
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -0
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +137 -0
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentD1.js +159 -0
- package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js +61 -0
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js +88 -0
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js +51 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +22 -0
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js +79 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +78 -0
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentR2.js +122 -0
- package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js +27 -0
- package/build/esm/prod/instrumentations/worker/instrumentRateLimit.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +75 -0
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -0
- package/build/esm/prod/instrumentations/worker/instrumentTail.js +57 -0
- package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -0
- package/build/esm/prod/integrations/fetch.js +117 -0
- package/build/esm/prod/integrations/fetch.js.map +1 -0
- package/build/esm/prod/integrations/httpServer.js +33 -0
- package/build/esm/prod/integrations/httpServer.js.map +1 -0
- package/build/esm/prod/integrations/spotlight.js +61 -0
- package/build/esm/prod/integrations/spotlight.js.map +1 -0
- package/build/esm/prod/integrations/tracing/vercelai.js +16 -0
- package/build/esm/prod/integrations/tracing/vercelai.js.map +1 -0
- package/build/esm/prod/opentelemetry/tracer.js +47 -0
- package/build/esm/prod/opentelemetry/tracer.js.map +1 -0
- package/build/esm/prod/options.js +31 -0
- package/build/esm/prod/options.js.map +1 -0
- package/build/esm/prod/package.json +1 -0
- package/build/esm/prod/pages-plugin.js +22 -0
- package/build/esm/prod/pages-plugin.js.map +1 -0
- package/build/esm/prod/request.js +129 -0
- package/build/esm/prod/request.js.map +1 -0
- package/build/esm/prod/scope-utils.js +18 -0
- package/build/esm/prod/scope-utils.js.map +1 -0
- package/build/esm/prod/sdk.js +16 -0
- package/build/esm/prod/sdk.js.map +1 -0
- package/build/esm/prod/transport.js +72 -0
- package/build/esm/prod/transport.js.map +1 -0
- package/build/esm/prod/utils/instrumentContext.js +61 -0
- package/build/esm/prod/utils/instrumentContext.js.map +1 -0
- package/build/esm/prod/utils/internalSqlQuery.js +23 -0
- package/build/esm/prod/utils/internalSqlQuery.js.map +1 -0
- package/build/esm/prod/utils/internalStorageKey.js +41 -0
- package/build/esm/prod/utils/internalStorageKey.js.map +1 -0
- package/build/esm/prod/utils/invocationScope.js +10 -0
- package/build/esm/prod/utils/invocationScope.js.map +1 -0
- package/build/esm/prod/utils/isBinding.js +29 -0
- package/build/esm/prod/utils/isBinding.js.map +1 -0
- package/build/esm/prod/utils/isCloudflareClass.js +21 -0
- package/build/esm/prod/utils/isCloudflareClass.js.map +1 -0
- package/build/esm/prod/utils/rpcMeta.js +35 -0
- package/build/esm/prod/utils/rpcMeta.js.map +1 -0
- package/build/esm/prod/utils/streaming.js +14 -0
- package/build/esm/prod/utils/streaming.js.map +1 -0
- package/build/esm/prod/utils/traceLinks.js +49 -0
- package/build/esm/prod/utils/traceLinks.js.map +1 -0
- package/build/esm/prod/vendor/stacktrace.js +25 -0
- package/build/esm/prod/vendor/stacktrace.js.map +1 -0
- package/build/esm/prod/vite/agentClass.js +111 -0
- package/build/esm/prod/vite/agentClass.js.map +1 -0
- package/build/esm/prod/vite/autoInstrument.js +92 -0
- package/build/esm/prod/vite/autoInstrument.js.map +1 -0
- package/build/esm/prod/vite/index.js +14 -0
- package/build/esm/prod/vite/index.js.map +1 -0
- package/build/esm/prod/vite/instrumentFile.js +27 -0
- package/build/esm/prod/vite/instrumentFile.js.map +1 -0
- package/build/esm/prod/vite/moduleShape.js +227 -0
- package/build/esm/prod/vite/moduleShape.js.map +1 -0
- package/build/esm/prod/vite/transform.js +147 -0
- package/build/esm/prod/vite/transform.js.map +1 -0
- package/build/esm/prod/vite/workerEntrypoint.js +64 -0
- package/build/esm/prod/vite/workerEntrypoint.js.map +1 -0
- package/build/esm/prod/vite/wranglerConfig.js +52 -0
- package/build/esm/prod/vite/wranglerConfig.js.map +1 -0
- package/build/esm/prod/withSentry.js +27 -0
- package/build/esm/prod/withSentry.js.map +1 -0
- package/build/esm/prod/workflows.js +136 -0
- package/build/esm/prod/workflows.js.map +1 -0
- package/build/esm/prod/wrapMethodWithSentry.js +132 -0
- package/build/esm/prod/wrapMethodWithSentry.js.map +1 -0
- package/build/types/baseSdk.d.ts +28 -0
- package/build/types/baseSdk.d.ts.map +1 -0
- package/build/types/client.d.ts +12 -39
- package/build/types/client.d.ts.map +1 -1
- package/build/types/defineCloudflareOptions.d.ts +2 -2
- package/build/types/defineCloudflareOptions.d.ts.map +1 -1
- package/build/types/durableobject.d.ts +5 -4
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -5
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/agents/types.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentDurableObjectStorage.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentSqlStorage.d.ts.map +1 -1
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts +2 -1
- package/build/types/instrumentations/instrumentWorkerEntrypoint.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentD1.d.ts +0 -16
- package/build/types/instrumentations/worker/instrumentD1.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEmail.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEnv.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentFetch.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentFetch.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentQueue.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentTail.d.ts +2 -2
- package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
- package/build/types/integrations/httpServer.d.ts.map +1 -1
- package/build/types/integrations/spotlight.d.ts +1 -1
- package/build/types/integrations/tracing/vercelai.d.ts +2 -10
- package/build/types/integrations/tracing/vercelai.d.ts.map +1 -1
- package/build/types/options.d.ts.map +1 -1
- package/build/types/pages-plugin.d.ts +1 -1
- package/build/types/pages-plugin.d.ts.map +1 -1
- package/build/types/request.d.ts +17 -2
- package/build/types/request.d.ts.map +1 -1
- package/build/types/sdk.d.ts +8 -3
- package/build/types/sdk.d.ts.map +1 -1
- package/build/types/transport.d.ts.map +1 -1
- package/build/types/types.d.ts +85 -0
- package/build/types/types.d.ts.map +1 -0
- package/build/types/utils/instrumentContext.d.ts.map +1 -1
- package/build/types/utils/isCloudflareClass.d.ts +1 -1
- package/build/types/utils/isCloudflareClass.d.ts.map +1 -1
- package/build/types/vite/autoInstrument.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +37 -61
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/withSentry.d.ts +2 -2
- package/build/types/withSentry.d.ts.map +1 -1
- package/build/types/workflows.d.ts +5 -4
- package/build/types/workflows.d.ts.map +1 -1
- package/package.json +28 -51
- package/build/cjs/async.js +0 -63
- package/build/cjs/async.js.map +0 -1
- package/build/cjs/client.js.map +0 -1
- package/build/cjs/debug-build.js.map +0 -1
- package/build/cjs/defineCloudflareOptions.js.map +0 -1
- package/build/cjs/durableobject.js.map +0 -1
- package/build/cjs/flush.js.map +0 -1
- package/build/cjs/instrument.js.map +0 -1
- package/build/cjs/instrumentations/agents/index.js.map +0 -1
- package/build/cjs/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
- package/build/cjs/instrumentations/agents/instrumentAgentRequestConversation.js.map +0 -1
- package/build/cjs/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
- package/build/cjs/instrumentations/agents/types.js.map +0 -1
- package/build/cjs/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
- package/build/cjs/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
- package/build/cjs/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
- package/build/cjs/instrumentations/instrumentSqlStorage.js.map +0 -1
- package/build/cjs/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentD1.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentEmail.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentEnv.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentFetch.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentFetcher.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentQueue.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentR2.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentRateLimit.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentScheduled.js.map +0 -1
- package/build/cjs/instrumentations/worker/instrumentTail.js.map +0 -1
- package/build/cjs/integrations/fetch.js.map +0 -1
- package/build/cjs/integrations/hono.js +0 -52
- package/build/cjs/integrations/hono.js.map +0 -1
- package/build/cjs/integrations/httpServer.js.map +0 -1
- package/build/cjs/integrations/spotlight.js.map +0 -1
- package/build/cjs/integrations/tracing/vercelai.js.map +0 -1
- package/build/cjs/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
- package/build/cjs/opentelemetry/tracer.js.map +0 -1
- package/build/cjs/options.js.map +0 -1
- package/build/cjs/pages-plugin.js.map +0 -1
- package/build/cjs/request.js.map +0 -1
- package/build/cjs/scope-utils.js.map +0 -1
- package/build/cjs/sdk.js.map +0 -1
- package/build/cjs/transport.js.map +0 -1
- package/build/cjs/utils/instrumentContext.js.map +0 -1
- package/build/cjs/utils/internalSqlQuery.js.map +0 -1
- package/build/cjs/utils/internalStorageKey.js.map +0 -1
- package/build/cjs/utils/invocationScope.js.map +0 -1
- package/build/cjs/utils/isBinding.js.map +0 -1
- package/build/cjs/utils/isCloudflareClass.js.map +0 -1
- package/build/cjs/utils/rpcMeta.js.map +0 -1
- package/build/cjs/utils/rpcOptions.js +0 -26
- package/build/cjs/utils/rpcOptions.js.map +0 -1
- package/build/cjs/utils/streaming.js.map +0 -1
- package/build/cjs/utils/traceLinks.js.map +0 -1
- package/build/cjs/vendor/stacktrace.js.map +0 -1
- package/build/cjs/vite/agentClass.js.map +0 -1
- package/build/cjs/vite/autoInstrument.js.map +0 -1
- package/build/cjs/vite/index.js.map +0 -1
- package/build/cjs/vite/instrumentFile.js.map +0 -1
- package/build/cjs/vite/moduleShape.js.map +0 -1
- package/build/cjs/vite/transform.js.map +0 -1
- package/build/cjs/vite/workerEntrypoint.js.map +0 -1
- package/build/cjs/vite/wranglerConfig.js.map +0 -1
- package/build/cjs/withSentry.js.map +0 -1
- package/build/cjs/workflows.js.map +0 -1
- package/build/cjs/wrapMethodWithSentry.js.map +0 -1
- package/build/esm/async.js +0 -61
- package/build/esm/async.js.map +0 -1
- package/build/esm/client.js.map +0 -1
- package/build/esm/debug-build.js.map +0 -1
- package/build/esm/defineCloudflareOptions.js.map +0 -1
- package/build/esm/durableobject.js.map +0 -1
- package/build/esm/flush.js.map +0 -1
- package/build/esm/index.js +0 -17
- package/build/esm/instrument.js.map +0 -1
- package/build/esm/instrumentations/agents/index.js.map +0 -1
- package/build/esm/instrumentations/agents/instrumentAgentCallableRpc.js.map +0 -1
- package/build/esm/instrumentations/agents/instrumentAgentRequestConversation.js.map +0 -1
- package/build/esm/instrumentations/agents/instrumentChatAgentConversation.js.map +0 -1
- package/build/esm/instrumentations/agents/types.js.map +0 -1
- package/build/esm/instrumentations/instrumentDurableObjectNamespace.js.map +0 -1
- package/build/esm/instrumentations/instrumentDurableObjectStorage.js.map +0 -1
- package/build/esm/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +0 -1
- package/build/esm/instrumentations/instrumentSqlStorage.js.map +0 -1
- package/build/esm/instrumentations/instrumentWorkerEntrypoint.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentD1.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentEmail.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentEnv.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentFetch.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentFetcher.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentQueue.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentQueueProducer.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentR2.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentRateLimit.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentScheduled.js.map +0 -1
- package/build/esm/instrumentations/worker/instrumentTail.js.map +0 -1
- package/build/esm/integrations/fetch.js.map +0 -1
- package/build/esm/integrations/hono.js +0 -49
- package/build/esm/integrations/hono.js.map +0 -1
- package/build/esm/integrations/httpServer.js.map +0 -1
- package/build/esm/integrations/spotlight.js.map +0 -1
- package/build/esm/integrations/tracing/vercelai.js.map +0 -1
- package/build/esm/nodejs_compat/index.js +0 -18
- package/build/esm/nodejs_compat/integrations/tracing/vercelai.js +0 -16
- package/build/esm/nodejs_compat/integrations/tracing/vercelai.js.map +0 -1
- package/build/esm/opentelemetry/tracer.js.map +0 -1
- package/build/esm/options.js.map +0 -1
- package/build/esm/package.json +0 -1
- package/build/esm/pages-plugin.js.map +0 -1
- package/build/esm/request.js.map +0 -1
- package/build/esm/scope-utils.js.map +0 -1
- package/build/esm/sdk.js.map +0 -1
- package/build/esm/transport.js.map +0 -1
- package/build/esm/utils/instrumentContext.js.map +0 -1
- package/build/esm/utils/internalSqlQuery.js.map +0 -1
- package/build/esm/utils/internalStorageKey.js.map +0 -1
- package/build/esm/utils/invocationScope.js.map +0 -1
- package/build/esm/utils/isBinding.js.map +0 -1
- package/build/esm/utils/isCloudflareClass.js.map +0 -1
- package/build/esm/utils/rpcMeta.js.map +0 -1
- package/build/esm/utils/rpcOptions.js +0 -24
- package/build/esm/utils/rpcOptions.js.map +0 -1
- package/build/esm/utils/streaming.js.map +0 -1
- package/build/esm/utils/traceLinks.js.map +0 -1
- package/build/esm/vendor/stacktrace.js.map +0 -1
- package/build/esm/vite/agentClass.js.map +0 -1
- package/build/esm/vite/autoInstrument.js.map +0 -1
- package/build/esm/vite/index.js.map +0 -1
- package/build/esm/vite/instrumentFile.js.map +0 -1
- package/build/esm/vite/moduleShape.js.map +0 -1
- package/build/esm/vite/transform.js.map +0 -1
- package/build/esm/vite/workerEntrypoint.js.map +0 -1
- package/build/esm/vite/wranglerConfig.js.map +0 -1
- package/build/esm/withSentry.js.map +0 -1
- package/build/esm/workflows.js.map +0 -1
- package/build/esm/wrapMethodWithSentry.js.map +0 -1
- package/build/types/async.d.ts +0 -11
- package/build/types/async.d.ts.map +0 -1
- package/build/types/integrations/hono.d.ts +0 -42
- package/build/types/integrations/hono.d.ts.map +0 -1
- package/build/types/nodejs_compat/index.d.ts +0 -4
- package/build/types/nodejs_compat/index.d.ts.map +0 -1
- package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
- package/build/types/nodejs_compat/integrations/tracing/vercelai.d.ts.map +0 -1
- package/build/types/utils/rpcOptions.d.ts +0 -13
- package/build/types/utils/rpcOptions.d.ts.map +0 -1
- package/build/types-ts3.8/async.d.ts +0 -11
- package/build/types-ts3.8/client.d.ts +0 -203
- package/build/types-ts3.8/debug-build.d.ts +0 -7
- package/build/types-ts3.8/defineCloudflareOptions.d.ts +0 -38
- package/build/types-ts3.8/durableobject.d.ts +0 -127
- package/build/types-ts3.8/executionContext.d.ts +0 -13
- package/build/types-ts3.8/flush.d.ts +0 -47
- package/build/types-ts3.8/index.d.ts +0 -19
- package/build/types-ts3.8/instrument.d.ts +0 -20
- package/build/types-ts3.8/instrumentations/agents/index.d.ts +0 -25
- package/build/types-ts3.8/instrumentations/agents/instrumentAgentCallableRpc.d.ts +0 -14
- package/build/types-ts3.8/instrumentations/agents/instrumentAgentRequestConversation.d.ts +0 -16
- package/build/types-ts3.8/instrumentations/agents/instrumentChatAgentConversation.d.ts +0 -23
- package/build/types-ts3.8/instrumentations/agents/types.d.ts +0 -94
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectNamespace.d.ts +0 -13
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectStorage.d.ts +0 -19
- package/build/types-ts3.8/instrumentations/instrumentDurableObjectSyncKvStorage.d.ts +0 -3
- package/build/types-ts3.8/instrumentations/instrumentSqlStorage.d.ts +0 -9
- package/build/types-ts3.8/instrumentations/instrumentWorkerEntrypoint.d.ts +0 -42
- package/build/types-ts3.8/instrumentations/worker/instrumentD1.d.ts +0 -19
- package/build/types-ts3.8/instrumentations/worker/instrumentEmail.d.ts +0 -8
- package/build/types-ts3.8/instrumentations/worker/instrumentEnv.d.ts +0 -18
- package/build/types-ts3.8/instrumentations/worker/instrumentFetch.d.ts +0 -12
- package/build/types-ts3.8/instrumentations/worker/instrumentFetcher.d.ts +0 -10
- package/build/types-ts3.8/instrumentations/worker/instrumentQueue.d.ts +0 -12
- package/build/types-ts3.8/instrumentations/worker/instrumentQueueProducer.d.ts +0 -10
- package/build/types-ts3.8/instrumentations/worker/instrumentR2.d.ts +0 -9
- package/build/types-ts3.8/instrumentations/worker/instrumentRateLimit.d.ts +0 -6
- package/build/types-ts3.8/instrumentations/worker/instrumentScheduled.d.ts +0 -12
- package/build/types-ts3.8/instrumentations/worker/instrumentTail.d.ts +0 -12
- package/build/types-ts3.8/integrations/fetch.d.ts +0 -19
- package/build/types-ts3.8/integrations/hono.d.ts +0 -42
- package/build/types-ts3.8/integrations/httpServer.d.ts +0 -63
- package/build/types-ts3.8/integrations/spotlight.d.ts +0 -22
- package/build/types-ts3.8/integrations/tracing/vercelai.d.ts +0 -47
- package/build/types-ts3.8/nodejs_compat/index.d.ts +0 -4
- package/build/types-ts3.8/nodejs_compat/integrations/tracing/vercelai.d.ts +0 -37
- package/build/types-ts3.8/opentelemetry/tracer.d.ts +0 -6
- package/build/types-ts3.8/options.d.ts +0 -17
- package/build/types-ts3.8/pages-plugin.d.ts +0 -34
- package/build/types-ts3.8/request.d.ts +0 -25
- package/build/types-ts3.8/scope-utils.d.ts +0 -15
- package/build/types-ts3.8/sdk.d.ts +0 -10
- package/build/types-ts3.8/transport.d.ts +0 -34
- package/build/types-ts3.8/utils/instrumentContext.d.ts +0 -16
- package/build/types-ts3.8/utils/internalSqlQuery.d.ts +0 -20
- package/build/types-ts3.8/utils/internalStorageKey.d.ts +0 -22
- package/build/types-ts3.8/utils/invocationScope.d.ts +0 -24
- package/build/types-ts3.8/utils/isBinding.d.ts +0 -77
- package/build/types-ts3.8/utils/isCloudflareClass.d.ts +0 -30
- package/build/types-ts3.8/utils/rpcMeta.d.ts +0 -23
- package/build/types-ts3.8/utils/rpcOptions.d.ts +0 -13
- package/build/types-ts3.8/utils/streaming.d.ts +0 -17
- package/build/types-ts3.8/utils/traceLinks.d.ts +0 -28
- package/build/types-ts3.8/vendor/stacktrace.d.ts +0 -11
- package/build/types-ts3.8/vite/agentClass.d.ts +0 -41
- package/build/types-ts3.8/vite/autoInstrument.d.ts +0 -22
- package/build/types-ts3.8/vite/index.d.ts +0 -98
- package/build/types-ts3.8/vite/instrumentFile.d.ts +0 -22
- package/build/types-ts3.8/vite/moduleShape.d.ts +0 -52
- package/build/types-ts3.8/vite/transform.d.ts +0 -65
- package/build/types-ts3.8/vite/workerEntrypoint.d.ts +0 -12
- package/build/types-ts3.8/vite/wranglerConfig.d.ts +0 -43
- package/build/types-ts3.8/withSentry.d.ts +0 -16
- package/build/types-ts3.8/workflows.d.ts +0 -25
- package/build/types-ts3.8/wrapMethodWithSentry.d.ts +0 -43
- /package/build/cjs/{client.js → dev/client.js} +0 -0
- /package/build/cjs/{debug-build.js → dev/debug-build.js} +0 -0
- /package/build/cjs/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
- /package/build/cjs/{flush.js → dev/flush.js} +0 -0
- /package/build/cjs/{instrument.js → dev/instrument.js} +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/agents/index.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentAgentRequestConversation.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
- /package/build/cjs/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
- /package/build/cjs/{integrations → dev/integrations}/spotlight.js +0 -0
- /package/build/cjs/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
- /package/build/cjs/{scope-utils.js → dev/scope-utils.js} +0 -0
- /package/build/cjs/{transport.js → dev/transport.js} +0 -0
- /package/build/cjs/{utils → dev/utils}/internalSqlQuery.js +0 -0
- /package/build/cjs/{utils → dev/utils}/internalStorageKey.js +0 -0
- /package/build/cjs/{utils → dev/utils}/invocationScope.js +0 -0
- /package/build/cjs/{utils → dev/utils}/isBinding.js +0 -0
- /package/build/cjs/{utils → dev/utils}/isCloudflareClass.js +0 -0
- /package/build/cjs/{utils → dev/utils}/rpcMeta.js +0 -0
- /package/build/cjs/{utils → dev/utils}/streaming.js +0 -0
- /package/build/cjs/{utils → dev/utils}/traceLinks.js +0 -0
- /package/build/cjs/{vendor → dev/vendor}/stacktrace.js +0 -0
- /package/build/cjs/{vite → dev/vite}/agentClass.js +0 -0
- /package/build/cjs/{vite → dev/vite}/autoInstrument.js +0 -0
- /package/build/cjs/{vite → dev/vite}/instrumentFile.js +0 -0
- /package/build/cjs/{vite → dev/vite}/moduleShape.js +0 -0
- /package/build/cjs/{vite → dev/vite}/transform.js +0 -0
- /package/build/cjs/{vite → dev/vite}/workerEntrypoint.js +0 -0
- /package/build/cjs/{vite → dev/vite}/wranglerConfig.js +0 -0
- /package/build/cjs/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +0 -0
- /package/build/esm/{client.js → dev/client.js} +0 -0
- /package/build/esm/{debug-build.js → dev/debug-build.js} +0 -0
- /package/build/esm/{defineCloudflareOptions.js → dev/defineCloudflareOptions.js} +0 -0
- /package/build/esm/{flush.js → dev/flush.js} +0 -0
- /package/build/esm/{instrument.js → dev/instrument.js} +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/agents/index.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentAgentCallableRpc.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentAgentRequestConversation.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/agents/instrumentChatAgentConversation.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectNamespace.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectStorage.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentDurableObjectSyncKvStorage.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/instrumentSqlStorage.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentFetcher.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentQueueProducer.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentR2.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentRateLimit.js +0 -0
- /package/build/esm/{instrumentations → dev/instrumentations}/worker/instrumentTail.js +0 -0
- /package/build/esm/{integrations → dev/integrations}/spotlight.js +0 -0
- /package/build/esm/{opentelemetry → dev/opentelemetry}/tracer.js +0 -0
- /package/build/esm/{scope-utils.js → dev/scope-utils.js} +0 -0
- /package/build/esm/{transport.js → dev/transport.js} +0 -0
- /package/build/esm/{utils → dev/utils}/internalSqlQuery.js +0 -0
- /package/build/esm/{utils → dev/utils}/internalStorageKey.js +0 -0
- /package/build/esm/{utils → dev/utils}/invocationScope.js +0 -0
- /package/build/esm/{utils → dev/utils}/isBinding.js +0 -0
- /package/build/esm/{utils → dev/utils}/isCloudflareClass.js +0 -0
- /package/build/esm/{utils → dev/utils}/rpcMeta.js +0 -0
- /package/build/esm/{utils → dev/utils}/streaming.js +0 -0
- /package/build/esm/{vendor → dev/vendor}/stacktrace.js +0 -0
- /package/build/esm/{vite → dev/vite}/agentClass.js +0 -0
- /package/build/esm/{vite → dev/vite}/autoInstrument.js +0 -0
- /package/build/esm/{vite → dev/vite}/instrumentFile.js +0 -0
- /package/build/esm/{vite → dev/vite}/moduleShape.js +0 -0
- /package/build/esm/{vite → dev/vite}/transform.js +0 -0
- /package/build/esm/{vite → dev/vite}/workerEntrypoint.js +0 -0
- /package/build/esm/{vite → dev/vite}/wranglerConfig.js +0 -0
- /package/build/esm/{wrapMethodWithSentry.js → dev/wrapMethodWithSentry.js} +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { isObjectLike, captureException } from '@sentry/core';
|
|
2
|
+
import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
|
|
3
|
+
import { ensureInstrumented, markAsInstrumented, getInstrumented } from './instrument.js';
|
|
4
|
+
import { instrumentEnv } from './instrumentations/worker/instrumentEnv.js';
|
|
5
|
+
import { getFinalOptions } from './options.js';
|
|
6
|
+
import { wrapRequestHandlerWithInit } from './request.js';
|
|
7
|
+
import { init } from './sdk.js';
|
|
8
|
+
import { instrumentContext } from './utils/instrumentContext.js';
|
|
9
|
+
import { hasRpcMeta } from './utils/rpcMeta.js';
|
|
10
|
+
import { instrumentCloudflareAgent } from './instrumentations/agents/index.js';
|
|
11
|
+
import { wrapMethodWithSentry } from './wrapMethodWithSentry.js';
|
|
12
|
+
|
|
13
|
+
function constructInstrumentedDurableObject(target, ctx, env, newTarget, optionsCallback) {
|
|
14
|
+
setAsyncLocalStorageAsyncContextStrategy();
|
|
15
|
+
const options = getFinalOptions(optionsCallback(env), env);
|
|
16
|
+
const context = instrumentContext(ctx);
|
|
17
|
+
const instrumentedEnv = instrumentEnv(env, options);
|
|
18
|
+
const prototype = newTarget.prototype ?? target.prototype;
|
|
19
|
+
const cachedFrameworkManagedMethods = frameworkManagedMethodsCache.get(prototype);
|
|
20
|
+
const methodsBeforeConstruction = cachedFrameworkManagedMethods ? void 0 : resolvePrototypeMethods(prototype);
|
|
21
|
+
const obj = Reflect.construct(target, [context, instrumentedEnv], newTarget);
|
|
22
|
+
const frameworkManagedMethods = resolveFrameworkManagedMethods(
|
|
23
|
+
prototype,
|
|
24
|
+
obj,
|
|
25
|
+
methodsBeforeConstruction,
|
|
26
|
+
cachedFrameworkManagedMethods
|
|
27
|
+
);
|
|
28
|
+
instrumentDurableObjectHandlers(obj, options, context);
|
|
29
|
+
return { obj, options, context, frameworkManagedMethods };
|
|
30
|
+
}
|
|
31
|
+
const frameworkManagedMethodsCache = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
function resolvePrototypeMethods(prototype) {
|
|
33
|
+
const methods = /* @__PURE__ */ new Map();
|
|
34
|
+
for (let current = prototype; current && current !== Object.prototype; current = Object.getPrototypeOf(current)) {
|
|
35
|
+
for (const name of Object.getOwnPropertyNames(current)) {
|
|
36
|
+
if (name === "constructor" || methods.has(name)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, name);
|
|
40
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
41
|
+
methods.set(name, descriptor.value);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return methods;
|
|
46
|
+
}
|
|
47
|
+
function resolveFrameworkManagedMethods(prototype, obj, methodsBeforeConstruction, cached) {
|
|
48
|
+
if (cached) {
|
|
49
|
+
return cached;
|
|
50
|
+
}
|
|
51
|
+
const methodsAfterConstruction = resolvePrototypeMethods(Object.getPrototypeOf(obj));
|
|
52
|
+
const managed = /* @__PURE__ */ new Set();
|
|
53
|
+
for (const [name, method] of methodsAfterConstruction) {
|
|
54
|
+
const before = methodsBeforeConstruction?.get(name);
|
|
55
|
+
if (before && before !== method) {
|
|
56
|
+
managed.add(name);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
frameworkManagedMethodsCache.set(prototype, managed);
|
|
60
|
+
return managed;
|
|
61
|
+
}
|
|
62
|
+
function instrumentDurableObjectHandlers(obj, options, context) {
|
|
63
|
+
if (obj.fetch && typeof obj.fetch === "function") {
|
|
64
|
+
obj.fetch = ensureInstrumented(
|
|
65
|
+
obj.fetch.bind(obj),
|
|
66
|
+
(original) => new Proxy(original, {
|
|
67
|
+
apply(target, thisArg, args) {
|
|
68
|
+
return wrapRequestHandlerWithInit(
|
|
69
|
+
{ options, request: args[0], context },
|
|
70
|
+
() => {
|
|
71
|
+
return Reflect.apply(target, thisArg, args);
|
|
72
|
+
},
|
|
73
|
+
init
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
if (obj.alarm && typeof obj.alarm === "function") {
|
|
80
|
+
obj.alarm = wrapMethodWithSentry(
|
|
81
|
+
{
|
|
82
|
+
options,
|
|
83
|
+
context,
|
|
84
|
+
spanName: "alarm",
|
|
85
|
+
spanOp: "function",
|
|
86
|
+
startNewTrace: true,
|
|
87
|
+
origin: "auto.faas.cloudflare.durable_object"
|
|
88
|
+
},
|
|
89
|
+
obj.alarm.bind(obj)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
if (obj.webSocketMessage && typeof obj.webSocketMessage === "function") {
|
|
93
|
+
obj.webSocketMessage = wrapMethodWithSentry(
|
|
94
|
+
{ options, context, spanName: "webSocketMessage", origin: "auto.faas.cloudflare.durable_object" },
|
|
95
|
+
obj.webSocketMessage.bind(obj)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (obj.webSocketClose && typeof obj.webSocketClose === "function") {
|
|
99
|
+
obj.webSocketClose = wrapMethodWithSentry(
|
|
100
|
+
{ options, context, spanName: "webSocketClose", origin: "auto.faas.cloudflare.durable_object" },
|
|
101
|
+
obj.webSocketClose.bind(obj)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
if (obj.webSocketError && typeof obj.webSocketError === "function") {
|
|
105
|
+
obj.webSocketError = wrapMethodWithSentry(
|
|
106
|
+
{ options, context, spanName: "webSocketError", origin: "auto.faas.cloudflare.durable_object" },
|
|
107
|
+
obj.webSocketError.bind(obj),
|
|
108
|
+
(_, error) => captureException(error, {
|
|
109
|
+
mechanism: {
|
|
110
|
+
type: "auto.faas.cloudflare.durable_object_websocket",
|
|
111
|
+
handled: false
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const RESERVED_RPC_METHOD_NAMES = /* @__PURE__ */ new Set([
|
|
118
|
+
"constructor",
|
|
119
|
+
"fetch",
|
|
120
|
+
"connect",
|
|
121
|
+
"alarm",
|
|
122
|
+
"webSocketMessage",
|
|
123
|
+
"webSocketClose",
|
|
124
|
+
"webSocketError",
|
|
125
|
+
"dup"
|
|
126
|
+
]);
|
|
127
|
+
const rpcInstanceStates = /* @__PURE__ */ new WeakMap();
|
|
128
|
+
function finalizeWithRpcInstrumentation(obj, options, context, excludedMethods) {
|
|
129
|
+
if (options.enableRpcTracePropagation === false) {
|
|
130
|
+
return obj;
|
|
131
|
+
}
|
|
132
|
+
rpcInstanceStates.set(obj, { options, context });
|
|
133
|
+
instrumentPrototypeRpcMethods(obj, excludedMethods);
|
|
134
|
+
return obj;
|
|
135
|
+
}
|
|
136
|
+
function getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods) {
|
|
137
|
+
if (RESERVED_RPC_METHOD_NAMES.has(methodName) || Object.prototype.hasOwnProperty.call(obj, methodName) || excludedMethods?.has(methodName)) {
|
|
138
|
+
return void 0;
|
|
139
|
+
}
|
|
140
|
+
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);
|
|
141
|
+
if (!descriptor || typeof descriptor.value !== "function" || getInstrumented(descriptor.value)) {
|
|
142
|
+
return void 0;
|
|
143
|
+
}
|
|
144
|
+
return descriptor;
|
|
145
|
+
}
|
|
146
|
+
function instrumentPrototypeRpcMethods(obj, excludedMethods) {
|
|
147
|
+
let prototype = Object.getPrototypeOf(obj);
|
|
148
|
+
while (prototype && prototype !== Object.prototype) {
|
|
149
|
+
for (const methodName of Object.getOwnPropertyNames(prototype)) {
|
|
150
|
+
const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);
|
|
151
|
+
if (!descriptor) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const wrapped = createRpcPrototypeWrapper(methodName, descriptor.value);
|
|
155
|
+
try {
|
|
156
|
+
Object.defineProperty(prototype, methodName, { ...descriptor, value: wrapped });
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
markAsInstrumented(wrapped);
|
|
160
|
+
}
|
|
161
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function createRpcPrototypeWrapper(methodName, originalMethod) {
|
|
165
|
+
const wrapper = function(...args) {
|
|
166
|
+
if (!hasRpcMeta(args)) {
|
|
167
|
+
return Reflect.apply(originalMethod, this, args);
|
|
168
|
+
}
|
|
169
|
+
const state = isObjectLike(this) ? rpcInstanceStates.get(this) : void 0;
|
|
170
|
+
if (!state) {
|
|
171
|
+
return Reflect.apply(originalMethod, this, args);
|
|
172
|
+
}
|
|
173
|
+
const tracedMethods = state.tracedMethods ?? (state.tracedMethods = /* @__PURE__ */ new Map());
|
|
174
|
+
let traced = tracedMethods.get(methodName);
|
|
175
|
+
if (!traced) {
|
|
176
|
+
traced = wrapMethodWithSentry(
|
|
177
|
+
{
|
|
178
|
+
options: state.options,
|
|
179
|
+
context: state.context,
|
|
180
|
+
spanName: methodName,
|
|
181
|
+
spanOp: "rpc",
|
|
182
|
+
origin: "auto.faas.cloudflare.durable_object"
|
|
183
|
+
},
|
|
184
|
+
originalMethod,
|
|
185
|
+
void 0,
|
|
186
|
+
true
|
|
187
|
+
);
|
|
188
|
+
tracedMethods.set(methodName, traced);
|
|
189
|
+
}
|
|
190
|
+
return Reflect.apply(traced, this, args);
|
|
191
|
+
};
|
|
192
|
+
Object.defineProperties(wrapper, {
|
|
193
|
+
name: { value: originalMethod.name, configurable: true },
|
|
194
|
+
length: { value: originalMethod.length, configurable: true }
|
|
195
|
+
});
|
|
196
|
+
return wrapper;
|
|
197
|
+
}
|
|
198
|
+
function instrumentDurableObjectWithSentry(optionsCallback, DurableObjectClass) {
|
|
199
|
+
return new Proxy(DurableObjectClass, {
|
|
200
|
+
construct(target, [ctx, env], newTarget) {
|
|
201
|
+
const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(
|
|
202
|
+
target,
|
|
203
|
+
ctx,
|
|
204
|
+
env,
|
|
205
|
+
newTarget,
|
|
206
|
+
optionsCallback
|
|
207
|
+
);
|
|
208
|
+
return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function instrumentAgentWithSentry(optionsCallback, AgentClass) {
|
|
213
|
+
return new Proxy(AgentClass, {
|
|
214
|
+
construct(target, [ctx, env], newTarget) {
|
|
215
|
+
const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(
|
|
216
|
+
target,
|
|
217
|
+
ctx,
|
|
218
|
+
env,
|
|
219
|
+
newTarget,
|
|
220
|
+
optionsCallback
|
|
221
|
+
);
|
|
222
|
+
instrumentCloudflareAgent(obj);
|
|
223
|
+
return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export { constructInstrumentedDurableObject, finalizeWithRpcInstrumentation, instrumentAgentWithSentry, instrumentDurableObjectWithSentry };
|
|
229
|
+
//# 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 { captureException, isObjectLike } from '@sentry/core';\nimport type { DurableObject } from 'cloudflare:workers';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport { ensureInstrumented, getInstrumented, markAsInstrumented } from './instrument';\nimport { instrumentEnv } from './instrumentations/worker/instrumentEnv';\nimport { getFinalOptions } from './options';\nimport { wrapRequestHandlerWithInit } from './request';\nimport { init } from './sdk';\nimport { instrumentContext } from './utils/instrumentContext';\nimport { hasRpcMeta } from './utils/rpcMeta';\nimport { instrumentCloudflareAgent } from './instrumentations/agents';\nimport type { DefaultEnv, ResolveEnv } from './types';\nimport { type UncheckedMethod, wrapMethodWithSentry } from './wrapMethodWithSentry';\n\n/**\n * The instrumented context passed between the shared construction helpers.\n *\n * This is intentionally `any` rather than `ReturnType<typeof instrumentContext<DurableObjectState>>`.\n * A concrete `DurableObjectState` here forces `tsc` to structurally relate its `storage: SqlStorage`\n * graph against the `ExecutionContext | InstrumentedDurableObjectState` parameter of\n * `wrapMethodWithSentry`, while the RPC-branded `DurableObject` from `cloudflare:workers` is also in\n * scope. That union comparison explodes (1296×1296) and hangs the type build. The original inline\n * implementation avoided this only incidentally, because `ctx` reached it as `any` through the Proxy\n * `construct` trap. Keeping the shared context `any` preserves that behavior.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InstrumentedDurableObjectContext = any;\n\n/**\n * Constructs a Durable Object instance and instruments its built-in handler methods\n * (`fetch`, `alarm`, `webSocketMessage`, `webSocketClose`, `webSocketError`).\n *\n * This is the shared construction path used by both {@link instrumentDurableObjectWithSentry}\n * and {@link instrumentAgentWithSentry}. It intentionally does NOT apply the RPC prototype-method\n * instrumentation — callers apply that last via {@link finalizeWithRpcInstrumentation}, after any\n * additional per-instance instrumentation has been layered onto the returned object.\n *\n * @internal\n */\nexport function constructInstrumentedDurableObject<E, T extends DurableObject<E>>(\n target: new (state: DurableObjectState, env: E) => T,\n ctx: DurableObjectState,\n env: E,\n newTarget: NewableFunction,\n optionsCallback: (env: E) => CloudflareOptions,\n): {\n obj: T;\n options: CloudflareOptions;\n context: InstrumentedDurableObjectContext;\n frameworkManagedMethods: ReadonlySet<string>;\n} {\n setAsyncLocalStorageAsyncContextStrategy();\n const options = getFinalOptions(optionsCallback(env), env);\n // See InstrumentedDurableObjectContext — `ctx` is widened to `any` so the concrete\n // `DurableObjectState` type never enters the checker's relation graph in this module.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const context = instrumentContext(ctx as any);\n const instrumentedEnv = instrumentEnv(env as Record<string, unknown>, options);\n\n const prototype = (newTarget as unknown as { prototype?: object }).prototype ?? target.prototype;\n const cachedFrameworkManagedMethods = frameworkManagedMethodsCache.get(prototype);\n const methodsBeforeConstruction = cachedFrameworkManagedMethods ? undefined : resolvePrototypeMethods(prototype);\n\n // Pass `newTarget` so that subclasses of the instrumented class (e.g. the wrapper classes\n // created by wrangler's local dev tooling or `@cloudflare/vitest-pool-workers`) keep their\n // own prototype — otherwise subclass methods disappear and `instanceof` checks break.\n const obj = Reflect.construct(target, [context, instrumentedEnv], newTarget) as T;\n\n const frameworkManagedMethods = resolveFrameworkManagedMethods(\n prototype,\n obj,\n methodsBeforeConstruction,\n cachedFrameworkManagedMethods,\n );\n\n instrumentDurableObjectHandlers(obj, options, context);\n\n return { obj, options, context, frameworkManagedMethods };\n}\n\nconst frameworkManagedMethodsCache = new WeakMap<object, ReadonlySet<string>>();\n\n/**\n * Collects the methods visible from a prototype, using normal property lookup precedence.\n * Methods inherited from `Object.prototype` are excluded because they cannot be Durable Object RPC methods.\n */\nfunction resolvePrototypeMethods(prototype: object | null): Map<string, unknown> {\n const methods = new Map<string, unknown>();\n\n for (let current = prototype; current && current !== Object.prototype; current = Object.getPrototypeOf(current)) {\n for (const name of Object.getOwnPropertyNames(current)) {\n // The first occurrence wins, mirroring what a property lookup on the instance would find\n if (name === 'constructor' || methods.has(name)) {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(current, name);\n\n if (descriptor && typeof descriptor.value === 'function') {\n methods.set(name, descriptor.value);\n }\n }\n }\n\n return methods;\n}\n\n/**\n * Finds methods that a framework replaced while constructing the first instance.\n *\n * Some frameworks register methods by function identity, so replacing one of their wrappers would\n * break dispatch. The result is cached because frameworks commonly install their wrappers only\n * once; later constructions would no longer reveal which methods they manage.\n */\nfunction resolveFrameworkManagedMethods(\n prototype: object,\n obj: object,\n methodsBeforeConstruction: Map<string, unknown> | undefined,\n cached: ReadonlySet<string> | undefined,\n): ReadonlySet<string> {\n if (cached) {\n return cached;\n }\n\n const methodsAfterConstruction = resolvePrototypeMethods(Object.getPrototypeOf(obj) as object);\n const managed = new Set<string>();\n\n for (const [name, method] of methodsAfterConstruction) {\n const before = methodsBeforeConstruction?.get(name);\n\n if (before && before !== method) {\n managed.add(name);\n }\n }\n\n frameworkManagedMethodsCache.set(prototype, managed);\n\n return managed;\n}\n\n/**\n * Instruments the built-in Durable Object handler methods on a constructed instance.\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 */\nfunction instrumentDurableObjectHandlers<E, T extends DurableObject<E>>(\n obj: T,\n options: CloudflareOptions,\n context: InstrumentedDurableObjectContext,\n): void {\n // Bind each built-in handler to this instance before wrapping.\n // See https://github.com/getsentry/sentry-javascript/issues/22328\n if (obj.fetch && typeof obj.fetch === 'function') {\n obj.fetch = ensureInstrumented(\n obj.fetch.bind(obj),\n original =>\n new Proxy(original, {\n apply(target, thisArg, args) {\n return wrapRequestHandlerWithInit(\n { options, request: args[0], context },\n () => {\n return Reflect.apply(target, thisArg, args);\n },\n init,\n );\n },\n }),\n );\n }\n\n if (obj.alarm && typeof obj.alarm === 'function') {\n // Alarms are independent invocations, so we start a new trace and link to the previous alarm\n obj.alarm = wrapMethodWithSentry(\n {\n options,\n context,\n spanName: 'alarm',\n spanOp: 'function',\n startNewTrace: true,\n origin: 'auto.faas.cloudflare.durable_object',\n },\n obj.alarm.bind(obj),\n );\n }\n\n if (obj.webSocketMessage && typeof obj.webSocketMessage === 'function') {\n obj.webSocketMessage = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketMessage', origin: 'auto.faas.cloudflare.durable_object' },\n obj.webSocketMessage.bind(obj),\n );\n }\n\n if (obj.webSocketClose && typeof obj.webSocketClose === 'function') {\n obj.webSocketClose = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketClose', origin: 'auto.faas.cloudflare.durable_object' },\n obj.webSocketClose.bind(obj),\n );\n }\n\n if (obj.webSocketError && typeof obj.webSocketError === 'function') {\n obj.webSocketError = wrapMethodWithSentry(\n { options, context, spanName: 'webSocketError', origin: 'auto.faas.cloudflare.durable_object' },\n obj.webSocketError.bind(obj),\n (_, error) =>\n captureException(error, {\n mechanism: {\n type: 'auto.faas.cloudflare.durable_object_websocket',\n handled: false,\n },\n }),\n );\n }\n}\n\ntype RpcInstanceState = {\n options: CloudflareOptions;\n context: InstrumentedDurableObjectContext;\n /** Per-instance cache of the traced method wrappers, keyed by method name. Created on first use. */\n tracedMethods?: Map<string, UncheckedMethod>;\n};\n\n/**\n * Method names the runtime never dispatches over RPC, so wrapping them buys no tracing.\n *\n * Mirrors `isReservedName` in workerd (`src/workerd/api/worker-rpc.c++`): the runtime rejects these\n * before any property lookup happens. `fetch`, `alarm` and the `webSocket*` handlers are also\n * instrumented per-instance as own properties, and `constructor` is on every prototype.\n */\nconst RESERVED_RPC_METHOD_NAMES: ReadonlySet<string> = new Set([\n 'constructor',\n 'fetch',\n 'connect',\n 'alarm',\n 'webSocketMessage',\n 'webSocketClose',\n 'webSocketError',\n 'dup',\n]);\n\n// Prototype wrappers are shared by all instances, while SDK options and traced method caches are not.\nconst rpcInstanceStates = new WeakMap<object, RpcInstanceState>();\n\n/**\n * Adds trace propagation to a constructed Durable Object's RPC methods.\n *\n * RPC methods are wrapped on the prototype because Cloudflare dispatches them with the Durable\n * Object instance as the receiver. This preserves native private-field access and keeps the methods\n * visible to Cloudflare's RPC dispatcher. Built-in handlers, Agent handlers, and methods managed by\n * another framework are left untouched.\n *\n * Call this after all per-instance instrumentation has been applied. If RPC trace propagation is\n * disabled, the object is returned unchanged.\n *\n * @param obj The constructed Durable Object instance.\n * @param options The resolved SDK options for this instance.\n * @param context The instrumented execution context for this instance.\n * @param excludedMethods Method names owned by another framework and therefore not safe to wrap.\n * @returns The same Durable Object instance, with eligible prototype methods instrumented.\n * @internal\n */\nexport function finalizeWithRpcInstrumentation<T extends object>(\n obj: T,\n options: CloudflareOptions,\n context: InstrumentedDurableObjectContext,\n excludedMethods?: ReadonlySet<string>,\n): T {\n // Skip RPC instrumentation only when explicitly opted out (enabled by default)\n if (options.enableRpcTracePropagation === false) {\n return obj;\n }\n\n rpcInstanceStates.set(obj, { options, context });\n\n instrumentPrototypeRpcMethods(obj, excludedMethods);\n\n return obj;\n}\n\n/**\n * Returns a prototype method when it is eligible for RPC instrumentation.\n */\nfunction getRpcMethodDescriptor(\n obj: object,\n prototype: object,\n methodName: string,\n excludedMethods?: ReadonlySet<string>,\n): PropertyDescriptor | undefined {\n if (\n RESERVED_RPC_METHOD_NAMES.has(methodName) ||\n Object.prototype.hasOwnProperty.call(obj, methodName) ||\n excludedMethods?.has(methodName)\n ) {\n return undefined;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(prototype, methodName);\n\n if (!descriptor || typeof descriptor.value !== 'function' || getInstrumented(descriptor.value)) {\n return undefined;\n }\n\n return descriptor;\n}\n\n/**\n * Wraps eligible methods on the instance's prototype chain once per class.\n */\nfunction instrumentPrototypeRpcMethods(obj: object, excludedMethods?: ReadonlySet<string>): void {\n let prototype: object | null = Object.getPrototypeOf(obj);\n\n while (prototype && prototype !== Object.prototype) {\n for (const methodName of Object.getOwnPropertyNames(prototype)) {\n const descriptor = getRpcMethodDescriptor(obj, prototype, methodName, excludedMethods);\n\n if (!descriptor) {\n continue;\n }\n\n const wrapped = createRpcPrototypeWrapper(methodName, descriptor.value as UncheckedMethod);\n\n try {\n Object.defineProperty(prototype, methodName, { ...descriptor, value: wrapped });\n } catch {}\n\n // Only the wrapper is marked, not the original method: `wrapMethodWithSentry` resolves\n // through the same global map and must not resolve the original to this wrapper,\n // which would recurse.\n markAsInstrumented(wrapped);\n }\n\n prototype = Object.getPrototypeOf(prototype);\n }\n}\n\n/**\n * Creates a prototype wrapper that traces RPC calls carrying Sentry metadata.\n *\n * The wrapper looks up SDK state from its receiver, allowing one prototype function to serve every\n * instance. Calls without RPC metadata or instance state use the original method directly. The\n * original function name and arity are preserved because frameworks may inspect them for dispatch.\n */\nfunction createRpcPrototypeWrapper(methodName: string, originalMethod: UncheckedMethod): UncheckedMethod {\n const wrapper = function (this: unknown, ...args: unknown[]): unknown {\n // Untraced calls are the common case — every internal call the instance makes to one of its\n // own methods lands here too — so check the arguments before touching per-instance state.\n if (!hasRpcMeta(args)) {\n return Reflect.apply(originalMethod, this, args);\n }\n\n const state = isObjectLike(this) ? rpcInstanceStates.get(this) : undefined;\n\n if (!state) {\n return Reflect.apply(originalMethod, this, args);\n }\n\n const tracedMethods = (state.tracedMethods ??= new Map());\n let traced = tracedMethods.get(methodName);\n\n if (!traced) {\n traced = wrapMethodWithSentry(\n {\n options: state.options,\n context: state.context,\n spanName: methodName,\n spanOp: 'rpc',\n origin: 'auto.faas.cloudflare.durable_object',\n },\n originalMethod,\n undefined,\n true,\n );\n tracedMethods.set(methodName, traced);\n }\n\n return Reflect.apply(traced, this, args);\n };\n\n Object.defineProperties(wrapper, {\n name: { value: originalMethod.name, configurable: true },\n length: { value: originalMethod.length, configurable: true },\n });\n\n return wrapper as UncheckedMethod;\n}\n\n/**\n * Instruments a Durable Object class to capture errors and performance data.\n *\n * Instruments the following methods by default:\n * - fetch\n * - alarm\n * - webSocketMessage\n * - webSocketClose\n * - webSocketError\n *\n * RPC methods (prototype methods) are instrumented by default. Set `enableRpcTracePropagation`\n * to `false` to opt out.\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<\n Env = DefaultEnv,\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends DurableObject<any> = DurableObject<Env>,\n // oxlint-disable-next-line typescript/no-explicit-any\n C extends new (state: DurableObjectState, env: any) => T = new (state: DurableObjectState, env: any) => T,\n>(optionsCallback: (env: ResolveEnv<C, Env>) => CloudflareOptions, DurableObjectClass: C): C {\n return new Proxy(DurableObjectClass, {\n construct(target, [ctx, env], newTarget) {\n const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(\n target,\n ctx,\n env,\n newTarget,\n optionsCallback,\n );\n\n return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);\n },\n });\n}\n\n/**\n * Instruments a Cloudflare [`agents`](https://www.npmjs.com/package/agents) Agent class with Sentry.\n *\n * An `Agent` is a Durable Object under the hood, so this applies the same instrumentation as\n * {@link instrumentDurableObjectWithSentry} (request transactions, `alarm`, WebSocket handlers, RPC\n * trace propagation, SQL spans) and additionally captures Agent-specific telemetry via\n * `instrumentCloudflareAgent`:\n *\n * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.\n * - **Breadcrumbs** — for every Agent observability event (`rpc`, `state:update`, `connect`,\n * `disconnect`, `schedule:*`, `queue:*`, `workflow:*`, `email:*`, `mcp:*`, ...).\n *\n * Cloudflare Workers cannot auto-instrument, so the Agent class must be wrapped manually.\n *\n * @param optionsCallback Function that returns the options for the SDK initialization.\n * @param AgentClass The Agent class to instrument.\n * @returns The instrumented Agent class.\n *\n * @example\n * ```ts\n * import { Agent, callable, routeAgentRequest } from 'agents';\n * import * as Sentry from '@sentry/cloudflare';\n *\n * class MyAgentBase extends Agent<Env> {\n * @callable()\n * async greet(name: string): Promise<string> {\n * return `Hello, ${name}!`;\n * }\n * }\n *\n * export const MyAgent = Sentry.instrumentAgentWithSentry(\n * env => ({\n * dsn: env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * }),\n * MyAgentBase,\n * );\n * ```\n */\nexport function instrumentAgentWithSentry<\n Env = DefaultEnv,\n // oxlint-disable-next-line typescript/no-explicit-any\n T extends DurableObject<any> = DurableObject<Env>,\n // oxlint-disable-next-line typescript/no-explicit-any\n C extends new (state: DurableObjectState, env: any) => T = new (state: DurableObjectState, env: any) => T,\n>(optionsCallback: (env: ResolveEnv<C, Env>) => CloudflareOptions, AgentClass: C): C {\n return new Proxy(AgentClass, {\n construct(target, [ctx, env], newTarget) {\n const { obj, options, context, frameworkManagedMethods } = constructInstrumentedDurableObject(\n target,\n ctx,\n env,\n newTarget,\n optionsCallback,\n );\n\n instrumentCloudflareAgent(obj);\n\n // Apply RPC prototype-method instrumentation last, so the Agent-specific own-property\n // handlers we just installed are excluded from RPC method tracing. Methods the Agent\n // framework installed itself are excluded too — `instrumentCloudflareAgent` traces those by\n // wrapping the dispatch instead of the method.\n return finalizeWithRpcInstrumentation(obj, options, context, frameworkManagedMethods);\n },\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAyCO,SAAS,kCAAA,CACd,MAAA,EACA,GAAA,EACA,GAAA,EACA,WACA,eAAA,EAMA;AACA,EAA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AAQ,cAAc,IAAA;AAAK,GAC5D,CAAA;AAED,EAAA,OAAO,OAAA;AACT;AAoCO,SAAS,iCAAA,CAMd,iBAAiE,kBAAA,EAA0B;AAC3F,EAAA,OAAO,IAAI,MAAM,kBAAA,EAAoB;AAAA,IACnC,UAAU,MAAA,EAAQ,CAAC,GAAA,EAAK,GAAG,GAAG,SAAA,EAAW;AACvC,MAAA,MAAM,EAAE,GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,yBAAwB,GAAI,kCAAA;AAAA,QACzD,MAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAA,OAAO,8BAAA,CAA+B,GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,uBAAuB,CAAA;AAAA,IACtF;AAAA,GACD,CAAA;AACH;AAyCO,SAAS,yBAAA,CAMd,iBAAiE,UAAA,EAAkB;AACnF,EAAA,OAAO,IAAI,MAAM,UAAA,EAAY;AAAA,IAC3B,UAAU,MAAA,EAAQ,CAAC,GAAA,EAAK,GAAG,GAAG,SAAA,EAAW;AACvC,MAAA,MAAM,EAAE,GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,yBAAwB,GAAI,kCAAA;AAAA,QACzD,MAAA;AAAA,QACA,GAAA;AAAA,QACA,GAAA;AAAA,QACA,SAAA;AAAA,QACA;AAAA,OACF;AAEA,MAAA,yBAAA,CAA0B,GAAG,CAAA;AAM7B,MAAA,OAAO,8BAAA,CAA+B,GAAA,EAAK,OAAA,EAAS,OAAA,EAAS,uBAAuB,CAAA;AAAA,IACtF;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { flush, debug } from '@sentry/core';
|
|
2
|
+
import { DEBUG_BUILD } from './debug-build.js';
|
|
3
|
+
|
|
4
|
+
const flushLockRegistries = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function getOriginalWaitUntil(context) {
|
|
6
|
+
const currentWaitUntil = context.waitUntil;
|
|
7
|
+
const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;
|
|
8
|
+
return original ?? currentWaitUntil;
|
|
9
|
+
}
|
|
10
|
+
function makeFlushLock(context) {
|
|
11
|
+
const registry = getOrCreateFlushLockRegistry(context);
|
|
12
|
+
let resolveAllDone = () => void 0;
|
|
13
|
+
const allDone = new Promise((res) => {
|
|
14
|
+
resolveAllDone = res;
|
|
15
|
+
});
|
|
16
|
+
let pending = 0;
|
|
17
|
+
const lock = {
|
|
18
|
+
ready: allDone,
|
|
19
|
+
acquire: () => {
|
|
20
|
+
pending++;
|
|
21
|
+
},
|
|
22
|
+
release: () => {
|
|
23
|
+
if (--pending === 0) {
|
|
24
|
+
registry.locks.delete(lock);
|
|
25
|
+
resolveAllDone();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
finalize: () => {
|
|
29
|
+
if (pending === 0) {
|
|
30
|
+
registry.locks.delete(lock);
|
|
31
|
+
resolveAllDone();
|
|
32
|
+
}
|
|
33
|
+
return allDone;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
registry.locks.add(lock);
|
|
37
|
+
return Object.freeze(lock);
|
|
38
|
+
}
|
|
39
|
+
function getOrCreateFlushLockRegistry(context) {
|
|
40
|
+
const waitUntil = context.waitUntil;
|
|
41
|
+
const existingRegistry = flushLockRegistries.get(waitUntil);
|
|
42
|
+
if (existingRegistry) {
|
|
43
|
+
return existingRegistry;
|
|
44
|
+
}
|
|
45
|
+
const originalWaitUntil = context.waitUntil.bind(context);
|
|
46
|
+
const registry = { locks: /* @__PURE__ */ new Set(), originalWaitUntil };
|
|
47
|
+
const instrumentedWaitUntil = (promise) => {
|
|
48
|
+
const locks = [...registry.locks];
|
|
49
|
+
for (const lock of locks) {
|
|
50
|
+
lock.acquire();
|
|
51
|
+
}
|
|
52
|
+
return originalWaitUntil(
|
|
53
|
+
promise.finally(() => {
|
|
54
|
+
for (const lock of locks) {
|
|
55
|
+
lock.release();
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
flushLockRegistries.set(instrumentedWaitUntil, registry);
|
|
61
|
+
context.waitUntil = instrumentedWaitUntil;
|
|
62
|
+
return registry;
|
|
63
|
+
}
|
|
64
|
+
async function flushAndDispose(client, timeout = 2e3) {
|
|
65
|
+
try {
|
|
66
|
+
if (!client) {
|
|
67
|
+
await flush(timeout);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await client.flush(timeout);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
DEBUG_BUILD && debug.warn("Failed to flush client", e);
|
|
73
|
+
} finally {
|
|
74
|
+
try {
|
|
75
|
+
client?.dispose();
|
|
76
|
+
} catch (e) {
|
|
77
|
+
DEBUG_BUILD && debug.warn("Failed to dispose client", e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export { flushAndDispose, getOriginalWaitUntil, makeFlushLock };
|
|
83
|
+
//# sourceMappingURL=flush.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flush.js","sources":["../../../src/flush.ts"],"sourcesContent":["import type { ExecutionContext } from '@cloudflare/workers-types';\nimport type { Client } from '@sentry/core';\nimport { debug, flush } from '@sentry/core';\nimport { DEBUG_BUILD } from './debug-build';\nimport type { ExecutionContextCompat } from './executionContext';\n\ntype FlushLock = {\n readonly ready: Promise<void>;\n readonly finalize: () => Promise<void>;\n};\n\ntype FlushLockRegistry = {\n readonly locks: Set<FlushLockInternal>;\n readonly originalWaitUntil: ExecutionContext['waitUntil'];\n};\n\ntype FlushLockInternal = FlushLock & {\n readonly acquire: () => void;\n readonly release: () => void;\n};\n\nconst flushLockRegistries = new WeakMap<ExecutionContext['waitUntil'], FlushLockRegistry>();\n\n/**\n * Returns the original (un-instrumented) waitUntil function for a context.\n * This should be used when calling waitUntil with flushAndDispose to avoid deadlock.\n *\n * The flush lock mechanism wraps context.waitUntil to track pending tasks.\n * If we call waitUntil(flushAndDispose(client)) through the instrumented version,\n * it creates a deadlock because:\n * 1. The instrumented waitUntil acquires the flush lock\n * 2. flushAndDispose calls client.flush() which waits for the lock to be released\n * 3. The lock won't be released until the waitUntil promise completes\n * 4. The waitUntil promise won't complete until flush() returns\n *\n * By using the original waitUntil for flush operations, we bypass this issue.\n */\nexport function getOriginalWaitUntil(context: ExecutionContextCompat): ExecutionContext['waitUntil'] {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const currentWaitUntil = context.waitUntil;\n const original = flushLockRegistries.get(currentWaitUntil)?.originalWaitUntil;\n return original ?? currentWaitUntil;\n}\n\n/**\n * Enhances the given execution context by wrapping its `waitUntil` method with a proxy\n * to monitor pending tasks, and provides a flusher function to ensure all tasks\n * have been completed before executing any subsequent logic.\n *\n * @param {ExecutionContext} context - The execution context to be enhanced. If no context is provided, the function returns undefined.\n * @return {FlushLock} Returns a flusher function if a valid context is provided, otherwise undefined.\n */\nexport function makeFlushLock(context: ExecutionContextCompat): FlushLock {\n const registry = getOrCreateFlushLockRegistry(context);\n let resolveAllDone: () => void = () => undefined;\n const allDone = new Promise<void>(res => {\n resolveAllDone = res;\n });\n let pending = 0;\n\n const lock: FlushLockInternal = {\n ready: allDone,\n acquire: () => {\n pending++;\n },\n release: () => {\n if (--pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n },\n finalize: () => {\n if (pending === 0) {\n registry.locks.delete(lock);\n resolveAllDone();\n }\n return allDone;\n },\n };\n\n registry.locks.add(lock);\n return Object.freeze(lock);\n}\n\nfunction getOrCreateFlushLockRegistry(context: ExecutionContextCompat): FlushLockRegistry {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const waitUntil = context.waitUntil;\n const existingRegistry = flushLockRegistries.get(waitUntil);\n\n if (existingRegistry) {\n return existingRegistry;\n }\n\n const originalWaitUntil = context.waitUntil.bind(context) as typeof context.waitUntil;\n const registry: FlushLockRegistry = { locks: new Set(), originalWaitUntil };\n const instrumentedWaitUntil: typeof context.waitUntil = promise => {\n // Snapshot active locks so locks created after this call do not wait for earlier waitUntil work.\n const locks = [...registry.locks];\n\n for (const lock of locks) {\n lock.acquire();\n }\n\n return originalWaitUntil(\n promise.finally(() => {\n for (const lock of locks) {\n lock.release();\n }\n }),\n );\n };\n\n flushLockRegistries.set(instrumentedWaitUntil, registry);\n context.waitUntil = instrumentedWaitUntil;\n\n return registry;\n}\n\n/**\n * Flushes the client and then disposes of it to allow garbage collection.\n * This should be called at the end of each request to prevent memory leaks.\n *\n * This function never rejects. On Workers, a rejected promise passed to\n * `ctx.waitUntil` marks the whole invocation as `outcome: exception` even when\n * the handler itself completed successfully. Since flush/dispose is internal\n * SDK housekeeping, a failure here must not fail the user's invocation.\n *\n * @param client - The CloudflareClient instance to flush and dispose\n * @param timeout - Timeout in milliseconds for the flush operation\n * @returns A promise that resolves when flush and dispose are complete\n */\nexport async function flushAndDispose(client: Client | undefined, timeout = 2000): Promise<void> {\n try {\n if (!client) {\n await flush(timeout);\n return;\n }\n await client.flush(timeout);\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to flush client', e);\n } finally {\n try {\n client?.dispose();\n } catch (e) {\n DEBUG_BUILD && debug.warn('Failed to dispose client', e);\n }\n }\n}\n"],"names":[],"mappings":";;;AAqBA,MAAM,mBAAA,uBAA0B,OAAA,EAA0D;AAgBnF,SAAS,qBAAqB,OAAA,EAAgE;AAEnG,EAAA,MAAM,mBAAmB,OAAA,CAAQ,SAAA;AACjC,EAAA,MAAM,QAAA,GAAW,mBAAA,CAAoB,GAAA,CAAI,gBAAgB,CAAA,EAAG,iBAAA;AAC5D,EAAA,OAAO,QAAA,IAAY,gBAAA;AACrB;AAUO,SAAS,cAAc,OAAA,EAA4C;AACxE,EAAA,MAAM,QAAA,GAAW,6BAA6B,OAAO,CAAA;AACrD,EAAA,IAAI,iBAA6B,MAAM,MAAA;AACvC,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA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,QAAQ,KAAA,EAAO;AACxB,MAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,IACf;AAEA,IAAA,OAAO,iBAAA;AAAA,MACL,OAAA,CAAQ,QAAQ,MAAM;AACpB,QAAA,KAAA,MAAW,QAAQ,KAAA,EAAO;AACxB,UAAA,IAAA,CAAK,OAAA,EAAQ;AAAA,QACf;AAAA,MACF,CAAC;AAAA,KACH;AAAA,EACF,CAAA;AAEA,EAAA,mBAAA,CAAoB,GAAA,CAAI,uBAAuB,QAAQ,CAAA;AACvD,EAAA,OAAA,CAAQ,SAAA,GAAY,qBAAA;AAEpB,EAAA,OAAO,QAAA;AACT;AAeA,eAAsB,eAAA,CAAgB,MAAA,EAA4B,OAAA,GAAU,GAAA,EAAqB;AAC/F,EAAA,IAAI;AACF,IAAA,IAAI,CAAC,MAAA,EAAQ;AACX,MAAA,MAAM,MAAM,OAAO,CAAA;AACnB,MAAA;AAAA,IACF;AACA,IAAA,MAAM,MAAA,CAAO,MAAM,OAAO,CAAA;AAAA,EAC5B,SAAS,CAAA,EAAG;AACV,IAAA,WAAA,IAAe,KAAA,CAAM,IAAA,CAAK,wBAAA,EAA0B,CAAC,CAAA;AAAA,EACvD,CAAA,SAAE;AACA,IAAA,IAAI;AACF,MAAA,MAAA,EAAQ,OAAA,EAAQ;AAAA,IAClB,SAAS,CAAA,EAAG;AACV,MAAA,WAAA,IAAe,KAAA,CAAM,IAAA,CAAK,0BAAA,EAA4B,CAAC,CAAA;AAAA,IACzD;AAAA,EACF;AACF;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { SDK_VERSION, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SAMPLE_RATE, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, Scope, addBreadcrumb, addEventProcessor, addIntegration, bindScopeToEmitter, captureCheckIn, captureConsoleIntegration, captureEvent, captureException, captureFeedback, captureMessage, close, consoleIntegration, consoleLoggingIntegration, continueTrace, createConsolaReporter, createTransport, dedupeIntegration, eventFiltersIntegration, extraErrorDataIntegration, featureFlagsIntegration, flush, functionToStringIntegration, getActiveSpan, getClient, getCurrentScope, getGlobalScope, getIsolationScope, getRootSpan, getSpanDescendants, getSpanStatusFromHttpCode, getTraceData, getTraceMetaTags, growthbookIntegration, instrumentPostgresJsSql, instrumentSupabaseClient, isEnabled, isInitialized, lastEventId, linkedErrorsIntegration, logger, metrics, moduleMetadataIntegration, requestDataIntegration, rewriteFramesIntegration, setAttribute, setAttributes, setContext, setConversationId, setCurrentClient, setExtra, setExtras, setHttpStatus, setMeasurement, setTag, setTags, setUser, spanStreamingIntegration, spanToBaggageHeader, spanToJSON, spanToStaticSpanJSON, spanToTraceHeader, startInactiveSpan, startNewTrace, startSpan, startSpanManual, supabaseIntegration, suppressTracing, trpcMiddleware, updateSpanName, withActiveSpan, withIsolationScope, withMonitor, withScope, withStaticSpan, withStreamedSpan, wrapMcpServerWithSentry, zodErrorsIntegration } from '@sentry/core';
|
|
2
|
+
export { withSentry } from './withSentry.js';
|
|
3
|
+
export { defineCloudflareOptions } from './defineCloudflareOptions.js';
|
|
4
|
+
export { instrumentAgentWithSentry, instrumentDurableObjectWithSentry } from './durableobject.js';
|
|
5
|
+
export { sentryPagesPlugin } from './pages-plugin.js';
|
|
6
|
+
export { CloudflareClient } from './client.js';
|
|
7
|
+
export { getDefaultIntegrations } from './sdk.js';
|
|
8
|
+
export { httpServerIntegration } from './integrations/httpServer.js';
|
|
9
|
+
export { fetchIntegration } from './integrations/fetch.js';
|
|
10
|
+
export { spotlightIntegration } from './integrations/spotlight.js';
|
|
11
|
+
export { vercelAIIntegration } from './integrations/tracing/vercelai.js';
|
|
12
|
+
export { createLangChainCallbackHandler, getOtlpTracesEndpoint, instrumentAnthropicAiClient, instrumentCreateReactAgent, instrumentGoogleGenAIClient, instrumentLangChainEmbeddings, instrumentOpenAiClient, instrumentStateGraph, instrumentWorkersAiClient, otlpIntegration, prismaIntegration } from '@sentry/server-utils';
|
|
13
|
+
export { instrumentWorkflowWithSentry } from './workflows.js';
|
|
14
|
+
export { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -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,48 @@
|
|
|
1
|
+
import { isObjectLike } from '@sentry/core';
|
|
2
|
+
|
|
3
|
+
const GLOBAL_KEY = "__SENTRY_INSTRUMENTED_MAP__";
|
|
4
|
+
function getInstrumentedMap() {
|
|
5
|
+
const globalObj = globalThis;
|
|
6
|
+
if (!globalObj[GLOBAL_KEY]) {
|
|
7
|
+
globalObj[GLOBAL_KEY] = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
}
|
|
9
|
+
return globalObj[GLOBAL_KEY];
|
|
10
|
+
}
|
|
11
|
+
function isWeakMapKey(value) {
|
|
12
|
+
return isObjectLike(value) || typeof value === "function";
|
|
13
|
+
}
|
|
14
|
+
function markAsInstrumented(original, instrumented) {
|
|
15
|
+
try {
|
|
16
|
+
if (isWeakMapKey(original)) {
|
|
17
|
+
getInstrumentedMap().set(original, instrumented ?? original);
|
|
18
|
+
}
|
|
19
|
+
if (isWeakMapKey(instrumented) && instrumented !== original) {
|
|
20
|
+
getInstrumentedMap().set(instrumented, instrumented);
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getInstrumented(obj) {
|
|
26
|
+
try {
|
|
27
|
+
if (isWeakMapKey(obj)) {
|
|
28
|
+
return getInstrumentedMap().get(obj);
|
|
29
|
+
}
|
|
30
|
+
return void 0;
|
|
31
|
+
} catch {
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function ensureInstrumented(original, instrumentFn, noMark) {
|
|
36
|
+
const existing = getInstrumented(original);
|
|
37
|
+
if (existing) {
|
|
38
|
+
return existing;
|
|
39
|
+
}
|
|
40
|
+
const instrumented = instrumentFn(original);
|
|
41
|
+
if (!noMark) {
|
|
42
|
+
markAsInstrumented(original, instrumented);
|
|
43
|
+
}
|
|
44
|
+
return instrumented;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { ensureInstrumented, getInstrumented, markAsInstrumented };
|
|
48
|
+
//# sourceMappingURL=instrument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.js","sources":["../../../src/instrument.ts"],"sourcesContent":["// Use a global WeakMap to track instrumented objects across module instances.\n// This is important for Cloudflare Workers where the module may be bundled\n// separately for workers and Durable Objects, but they share the same global scope.\n// The WeakMap stores original -> instrumented mappings so we can retrieve the\n// instrumented version even if we only have a reference to the original.\nimport { isObjectLike } from '@sentry/core';\n\nconst GLOBAL_KEY = '__SENTRY_INSTRUMENTED_MAP__' as const;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction getInstrumentedMap(): WeakMap<any, any> {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const globalObj = globalThis as typeof globalThis & { [GLOBAL_KEY]?: WeakMap<any, any> };\n if (!globalObj[GLOBAL_KEY]) {\n globalObj[GLOBAL_KEY] = new WeakMap();\n }\n return globalObj[GLOBAL_KEY];\n}\n\n/**\n * Check if a value can be used as a WeakMap key.\n * WeakMap keys must be objects or non-registered symbols.\n */\nfunction isWeakMapKey(value: unknown): value is object {\n return isObjectLike(value) || typeof value === 'function';\n}\n\n/**\n * Mark an object as instrumented, storing the instrumented version.\n * @param original The original uninstrumented object\n * @param instrumented The instrumented version (defaults to original if not provided)\n */\nexport function markAsInstrumented<T>(original: T, instrumented?: T): void {\n try {\n if (isWeakMapKey(original)) {\n // Store mapping from original to instrumented version\n // If instrumented is not provided, store original (for backwards compat)\n getInstrumentedMap().set(original, instrumented ?? original);\n }\n // Also mark the instrumented version itself so we recognize it\n if (isWeakMapKey(instrumented) && instrumented !== original) {\n getInstrumentedMap().set(instrumented, instrumented);\n }\n } catch {\n // ignore errors here\n }\n}\n\n/**\n * Get the instrumented version of an object, if available.\n * Returns the instrumented version if the object was previously instrumented,\n * or undefined if not found.\n */\nexport function getInstrumented<T>(obj: T): T | undefined {\n try {\n if (isWeakMapKey(obj)) {\n return getInstrumentedMap().get(obj) as T | undefined;\n }\n\n return undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Returns the already-instrumented version of `original` if one exists,\n * otherwise calls `instrumentFn` to create it, marks the mapping, and returns it.\n *\n * @param noMark - If true, skips storing the original→instrumented mapping.\n */\nexport function ensureInstrumented<T>(original: T, instrumentFn: (original: T) => T, noMark?: boolean): T {\n const existing = getInstrumented(original);\n\n if (existing) {\n return existing;\n }\n\n const instrumented = instrumentFn(original);\n\n if (!noMark) {\n markAsInstrumented(original, instrumented);\n }\n\n return instrumented;\n}\n"],"names":[],"mappings":";;AAOA,MAAM,UAAA,GAAa,6BAAA;AAGnB,SAAS,kBAAA,GAAwC;AAE/C,EAAA,MAAM,SAAA,GAAY,UAAA;AAClB,EAAA,IAAI,CAAC,SAAA,CAAU,UAAU,CAAA,EAAG;AAC1B,IAAA,SAAA,CAAU,UAAU,CAAA,mBAAI,IAAI,OAAA,EAAQ;AAAA,EACtC;AACA,EAAA,OAAO,UAAU,UAAU,CAAA;AAC7B;AAMA,SAAS,aAAa,KAAA,EAAiC;AACrD,EAAA,OAAO,YAAA,CAAa,KAAK,CAAA,IAAK,OAAO,KAAA,KAAU,UAAA;AACjD;AAOO,SAAS,kBAAA,CAAsB,UAAa,YAAA,EAAwB;AACzE,EAAA,IAAI;AACF,IAAA,IAAI,YAAA,CAAa,QAAQ,CAAA,EAAG;AAG1B,MAAA,kBAAA,EAAmB,CAAE,GAAA,CAAI,QAAA,EAAU,YAAA,IAAgB,QAAQ,CAAA;AAAA,IAC7D;AAEA,IAAA,IAAI,YAAA,CAAa,YAAY,CAAA,IAAK,YAAA,KAAiB,QAAA,EAAU;AAC3D,MAAA,kBAAA,EAAmB,CAAE,GAAA,CAAI,YAAA,EAAc,YAAY,CAAA;AAAA,IACrD;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AACF;AAOO,SAAS,gBAAmB,GAAA,EAAuB;AACxD,EAAA,IAAI;AACF,IAAA,IAAI,YAAA,CAAa,GAAG,CAAA,EAAG;AACrB,MAAA,OAAO,kBAAA,EAAmB,CAAE,GAAA,CAAI,GAAG,CAAA;AAAA,IACrC;AAEA,IAAA,OAAO,KAAA,CAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF;AAQO,SAAS,kBAAA,CAAsB,QAAA,EAAa,YAAA,EAAkC,MAAA,EAAqB;AACxG,EAAA,MAAM,QAAA,GAAW,gBAAgB,QAAQ,CAAA;AAEzC,EAAA,IAAI,QAAA,EAAU;AACZ,IAAA,OAAO,QAAA;AAAA,EACT;AAEA,EAAA,MAAM,YAAA,GAAe,aAAa,QAAQ,CAAA;AAE1C,EAAA,IAAI,CAAC,MAAA,EAAQ;AACX,IAAA,kBAAA,CAAmB,UAAU,YAAY,CAAA;AAAA,EAC3C;AAEA,EAAA,OAAO,YAAA;AACT;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { instrumentAgentCallableRpc } from './instrumentAgentCallableRpc.js';
|
|
2
|
+
import { instrumentAgentRequestConversation } from './instrumentAgentRequestConversation.js';
|
|
3
|
+
import { instrumentChatAgentConversation } from './instrumentChatAgentConversation.js';
|
|
4
|
+
|
|
5
|
+
function instrumentCloudflareAgent(agent) {
|
|
6
|
+
const internals = agent;
|
|
7
|
+
instrumentAgentCallableRpc(internals);
|
|
8
|
+
instrumentChatAgentConversation(internals);
|
|
9
|
+
instrumentAgentRequestConversation(internals);
|
|
10
|
+
return agent;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { instrumentCloudflareAgent };
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../src/instrumentations/agents/index.ts"],"sourcesContent":["import { instrumentAgentCallableRpc } from './instrumentAgentCallableRpc';\nimport { instrumentAgentRequestConversation } from './instrumentAgentRequestConversation';\nimport { instrumentChatAgentConversation } from './instrumentChatAgentConversation';\nimport type { AgentInternals } from './types';\n\n/**\n * Instruments an instance of a Cloudflare [`agents`](https://www.npmjs.com/package/agents) `Agent`\n * with Sentry, adding telemetry that is specific to the Agent's runtime behavior:\n *\n * - **Callable RPC spans** — a span (op `rpc`) for each `@callable()` method invoked over WebSocket.\n * - **Conversation correlation** — sets the conversation id on the scope for each unit of agent\n * work — chat turn, callable RPC call, or HTTP request — so `gen_ai` spans created within it are\n * correlated, for chat and plain agents alike. The id is minted once per agent instance and\n * rotated when the chat is cleared (the `message:clear` observability event); it is persisted to\n * Durable Object storage so it survives hibernation.\n *\n * It only hooks the `agents` package internals and uses Sentry's tracing primitives. On Cloudflare\n * Workers, prefer `instrumentAgentWithSentry`, which additionally instruments the Durable Object\n * handlers and initializes the SDK; that function calls this one internally.\n *\n * The hooks replace own-properties on the instance and defer to the original implementation, so\n * they compose with any other instrumentation applied to the same instance.\n *\n * @param agent The `agents` `Agent` instance to instrument.\n * @returns The same instance, instrumented.\n *\n * @internal Use `instrumentAgentWithSentry` instead — this is called internally by it.\n */\nexport function instrumentCloudflareAgent<T extends object>(agent: T): T {\n const internals = agent as T & AgentInternals;\n\n instrumentAgentCallableRpc(internals);\n instrumentChatAgentConversation(internals);\n instrumentAgentRequestConversation(internals);\n\n return agent;\n}\n"],"names":[],"mappings":";;;;AA4BO,SAAS,0BAA4C,KAAA,EAAa;AACvE,EAAA,MAAM,SAAA,GAAY,KAAA;AAElB,EAAA,0BAAA,CAA2B,SAAS,CAAA;AACpC,EAAA,+BAAA,CAAgC,SAAS,CAAA;AACzC,EAAA,kCAAA,CAAmC,SAAS,CAAA;AAE5C,EAAA,OAAO,KAAA;AACT;;;;"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { debug, startSpan, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_OP } from '@sentry/core';
|
|
2
|
+
import { DEBUG_BUILD } from '../../debug-build.js';
|
|
3
|
+
import { AGENT_SPAN_ORIGIN, getAgentAttributes, setAgentConversationId } from './types.js';
|
|
4
|
+
|
|
5
|
+
function instrumentAgentCallableRpc(obj) {
|
|
6
|
+
const original = obj.onMessage;
|
|
7
|
+
if (typeof original !== "function") {
|
|
8
|
+
DEBUG_BUILD && debug.log("[Sentry] Agent `onMessage` not found \u2014 callable RPC span instrumentation skipped.");
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
obj.onMessage = new Proxy(original, {
|
|
12
|
+
apply(target, thisArg, args) {
|
|
13
|
+
const method = extractCallableMethod(args[1]);
|
|
14
|
+
if (!method) {
|
|
15
|
+
return Reflect.apply(target, thisArg, args);
|
|
16
|
+
}
|
|
17
|
+
return startSpan(
|
|
18
|
+
{
|
|
19
|
+
name: method,
|
|
20
|
+
attributes: {
|
|
21
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: "rpc",
|
|
22
|
+
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: AGENT_SPAN_ORIGIN,
|
|
23
|
+
...getAgentAttributes(thisArg)
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async () => {
|
|
27
|
+
await setAgentConversationId(thisArg);
|
|
28
|
+
return Reflect.apply(target, thisArg, args);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function extractCallableMethod(message) {
|
|
35
|
+
const text = typeof message === "string" ? message : message instanceof ArrayBuffer ? new TextDecoder().decode(message) : void 0;
|
|
36
|
+
if (!text) {
|
|
37
|
+
return void 0;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(text);
|
|
41
|
+
if (parsed.type === "rpc" && typeof parsed.method === "string" && Array.isArray(parsed.args)) {
|
|
42
|
+
return parsed.method;
|
|
43
|
+
}
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { instrumentAgentCallableRpc };
|
|
50
|
+
//# sourceMappingURL=instrumentAgentCallableRpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentAgentCallableRpc.js","sources":["../../../../../src/instrumentations/agents/instrumentAgentCallableRpc.ts"],"sourcesContent":["import { debug, SEMANTIC_ATTRIBUTE_SENTRY_OP, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, startSpan } from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { AGENT_SPAN_ORIGIN, type AgentInternals, getAgentAttributes, setAgentConversationId } from './types';\n\n/**\n * Wraps the Agent's `onMessage` handler to create a span for each `@callable()` RPC invocation.\n * RPC requests arrive as WebSocket messages, so this span nests under the active transaction for\n * the WebSocket message (on Cloudflare, the instrumented Durable Object `webSocketMessage` hook).\n *\n * Also sets the conversation id on the scope for the duration of the call: callable methods are the\n * unit of work for plain (non-chat) agents, which run LLM calls just like chat turns do. It is\n * awaited so the id is on the scope before the method body creates any span; the `agents`\n * `onMessage` own property this wraps is already `async`, so the promise return is nothing new to\n * the WebSocket dispatch upstream.\n */\nexport function instrumentAgentCallableRpc(obj: AgentInternals): void {\n const original = obj.onMessage;\n if (typeof original !== 'function') {\n DEBUG_BUILD && debug.log('[Sentry] Agent `onMessage` not found — callable RPC span instrumentation skipped.');\n return;\n }\n\n obj.onMessage = new Proxy(original, {\n apply(target, thisArg: AgentInternals, args: unknown[]): unknown {\n const method = extractCallableMethod(args[1]);\n\n if (!method) {\n return Reflect.apply(target, thisArg, args);\n }\n\n return startSpan(\n {\n name: method,\n attributes: {\n [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'rpc',\n [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: AGENT_SPAN_ORIGIN,\n ...getAgentAttributes(thisArg),\n },\n },\n async () => {\n await setAgentConversationId(thisArg);\n return Reflect.apply(target, thisArg, args);\n },\n );\n },\n });\n}\n\n/** Extracts the RPC method name from a WebSocket message, mirroring the SDK's `isRPCRequest`. */\nfunction extractCallableMethod(message: unknown): string | undefined {\n const text =\n typeof message === 'string'\n ? message\n : message instanceof ArrayBuffer\n ? new TextDecoder().decode(message)\n : undefined;\n\n if (!text) {\n return undefined;\n }\n\n try {\n const parsed = JSON.parse(text) as { type?: unknown; method?: unknown; args?: unknown };\n if (parsed.type === 'rpc' && typeof parsed.method === 'string' && Array.isArray(parsed.args)) {\n return parsed.method;\n }\n } catch {\n // Not JSON, or not an RPC request — no span.\n }\n\n return undefined;\n}\n"],"names":[],"mappings":";;;;AAeO,SAAS,2BAA2B,GAAA,EAA2B;AACpE,EAAA,MAAM,WAAW,GAAA,CAAI,SAAA;AACrB,EAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,IAAA,WAAA,IAAe,KAAA,CAAM,IAAI,wFAAmF,CAAA;AAC5G,IAAA;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,SAAA,GAAY,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,IAClC,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAA0B;AAC/D,MAAA,MAAM,MAAA,GAAS,qBAAA,CAAsB,IAAA,CAAK,CAAC,CAAC,CAAA;AAE5C,MAAA,IAAI,CAAC,MAAA,EAAQ;AACX,QAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,MAC5C;AAEA,MAAA,OAAO,SAAA;AAAA,QACL;AAAA,UACE,IAAA,EAAM,MAAA;AAAA,UACN,UAAA,EAAY;AAAA,YACV,CAAC,4BAA4B,GAAG,KAAA;AAAA,YAChC,CAAC,gCAAgC,GAAG,iBAAA;AAAA,YACpC,GAAG,mBAAmB,OAAO;AAAA;AAC/B,SACF;AAAA,QACA,YAAY;AACV,UAAA,MAAM,uBAAuB,OAAO,CAAA;AACpC,UAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,QAC5C;AAAA,OACF;AAAA,IACF;AAAA,GACD,CAAA;AACH;AAGA,SAAS,sBAAsB,OAAA,EAAsC;AACnE,EAAA,MAAM,IAAA,GACJ,OAAO,OAAA,KAAY,QAAA,GACf,OAAA,GACA,OAAA,YAAmB,WAAA,GACjB,IAAI,WAAA,EAAY,CAAE,MAAA,CAAO,OAAO,CAAA,GAChC,MAAA;AAER,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI;AACF,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,KAAA,CAAM,IAAI,CAAA;AAC9B,IAAA,IAAI,MAAA,CAAO,IAAA,KAAS,KAAA,IAAS,OAAO,MAAA,CAAO,MAAA,KAAW,QAAA,IAAY,KAAA,CAAM,OAAA,CAAQ,MAAA,CAAO,IAAI,CAAA,EAAG;AAC5F,MAAA,OAAO,MAAA,CAAO,MAAA;AAAA,IAChB;AAAA,EACF,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { setAgentConversationId } from './types.js';
|
|
2
|
+
|
|
3
|
+
function instrumentAgentRequestConversation(obj) {
|
|
4
|
+
const original = obj.onRequest;
|
|
5
|
+
if (typeof original !== "function") {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
obj.onRequest = new Proxy(original, {
|
|
9
|
+
async apply(target, thisArg, args) {
|
|
10
|
+
await setAgentConversationId(thisArg);
|
|
11
|
+
return Reflect.apply(target, thisArg, args);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { instrumentAgentRequestConversation };
|
|
17
|
+
//# sourceMappingURL=instrumentAgentRequestConversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentAgentRequestConversation.js","sources":["../../../../../src/instrumentations/agents/instrumentAgentRequestConversation.ts"],"sourcesContent":["import { type AgentInternals, setAgentConversationId } from './types';\n\n/**\n * Correlates the AI spans of an HTTP-driven agent turn with a conversation id on the active scope.\n *\n * `onRequest` is the third unit of agent work, alongside chat turns and `@callable()` RPC: the\n * `agents` router sends every non-WebSocket request to it, which is how REST endpoints and webhooks\n * reach an agent.\n *\n * `agents` installs `onRequest` as an own property in the `Agent` constructor (as it does\n * `onMessage`), and we instrument after construction, so wrapping the own property is what the\n * router ends up calling. That own property is already `async`, and partyserver's `fetch` awaits it,\n * so returning a promise from this wrapper — to get the conversation id onto the scope before the\n * request handler creates any span — keeps the existing contract.\n */\nexport function instrumentAgentRequestConversation(obj: AgentInternals): void {\n const original = obj.onRequest;\n\n if (typeof original !== 'function') {\n return;\n }\n\n obj.onRequest = new Proxy(original, {\n async apply(target, thisArg: AgentInternals, args: unknown[]): Promise<unknown> {\n await setAgentConversationId(thisArg);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n}\n"],"names":[],"mappings":";;AAeO,SAAS,mCAAmC,GAAA,EAA2B;AAC5E,EAAA,MAAM,WAAW,GAAA,CAAI,SAAA;AAErB,EAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,SAAA,GAAY,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,IAClC,MAAM,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAAmC;AAC9E,MAAA,MAAM,uBAAuB,OAAO,CAAA;AAEpC,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,IAC5C;AAAA,GACD,CAAA;AACH;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { uuid4 } from '@sentry/core';
|
|
2
|
+
import { storeAgentConversationId, setAgentConversationId } from './types.js';
|
|
3
|
+
|
|
4
|
+
function instrumentChatAgentConversation(obj) {
|
|
5
|
+
const originalEmit = obj._emit;
|
|
6
|
+
if (typeof originalEmit === "function") {
|
|
7
|
+
obj._emit = new Proxy(originalEmit, {
|
|
8
|
+
apply(target, thisArg, args) {
|
|
9
|
+
if (args[0] === "message:clear") {
|
|
10
|
+
storeAgentConversationId(thisArg, uuid4());
|
|
11
|
+
}
|
|
12
|
+
return Reflect.apply(target, thisArg, args);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
const original = obj.onChatMessage;
|
|
17
|
+
if (typeof original !== "function") {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
obj.onChatMessage = new Proxy(original, {
|
|
21
|
+
async apply(target, thisArg, args) {
|
|
22
|
+
await setAgentConversationId(thisArg);
|
|
23
|
+
return Reflect.apply(target, thisArg, args);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { instrumentChatAgentConversation };
|
|
29
|
+
//# sourceMappingURL=instrumentChatAgentConversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentChatAgentConversation.js","sources":["../../../../../src/instrumentations/agents/instrumentChatAgentConversation.ts"],"sourcesContent":["import { uuid4 } from '@sentry/core';\nimport { type AgentInternals, setAgentConversationId, storeAgentConversationId } from './types';\n\n/**\n * For chat agents (`AIChatAgent` from `@cloudflare/ai-chat`), correlates each chat turn's AI spans\n * with a conversation id on the active scope.\n *\n * In the Agents model one agent instance is one long-lived conversation, so the conversation id is\n * minted once per instance and persisted to Durable Object storage, which is what carries it across\n * hibernation (that destroys the in-memory instance). When the user clears the chat, they expect a\n * fresh conversation — but recreating the Durable Object for that would also drop the MCP/OAuth\n * state stored per instance (GitHub/Sentry sign-in). To get a fresh conversation id *without*\n * losing that state, we rotate the persisted id when the SDK reports a cleared chat.\n *\n * The id itself is not attached to spans here — `setAgentConversationId` resolves it, and the SDK's\n * `conversationIdIntegration` picks it off the scope at `spanStart` to stamp\n * `gen_ai.conversation.id` onto the AI spans created inside the turn (e.g. by the Workers AI\n * instrumentation), which correlates a turn's model and tool calls.\n *\n * Plain (non-chat) `Agent`s do not define `onChatMessage`, so they are skipped here — their unit\n * of work is the callable RPC method, where `instrumentAgentCallableRpc` sets the conversation id\n * instead.\n */\nexport function instrumentChatAgentConversation(obj: AgentInternals): void {\n // Rotate the conversation id when the chat is cleared. `_emit` is the central choke-point through\n // which all `agents:*` observability events are published, and it already exists on the base\n // `Agent` class — so this hook composes with the RPC instrumentation, which keys off the same\n // surface. We shadow it with an own property so the original stays reachable on the prototype.\n const originalEmit = obj._emit;\n\n if (typeof originalEmit === 'function') {\n obj._emit = new Proxy(originalEmit, {\n apply(target, thisArg: AgentInternals, args: [string, Record<string, unknown>?]) {\n if (args[0] === 'message:clear') {\n storeAgentConversationId(thisArg, uuid4());\n }\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n }\n\n const original = obj.onChatMessage;\n\n if (typeof original !== 'function') {\n return;\n }\n\n obj.onChatMessage = new Proxy(original, {\n async apply(target, thisArg: AgentInternals, args: unknown[]): Promise<unknown> {\n await setAgentConversationId(thisArg);\n\n return Reflect.apply(target, thisArg, args);\n },\n });\n}\n"],"names":[],"mappings":";;;AAuBO,SAAS,gCAAgC,GAAA,EAA2B;AAKzE,EAAA,MAAM,eAAe,GAAA,CAAI,KAAA;AAEzB,EAAA,IAAI,OAAO,iBAAiB,UAAA,EAAY;AACtC,IAAA,GAAA,CAAI,KAAA,GAAQ,IAAI,KAAA,CAAM,YAAA,EAAc;AAAA,MAClC,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAA0C;AAC/E,QAAA,IAAI,IAAA,CAAK,CAAC,CAAA,KAAM,eAAA,EAAiB;AAC/B,UAAA,wBAAA,CAAyB,OAAA,EAAS,OAAO,CAAA;AAAA,QAC3C;AAEA,QAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,MAC5C;AAAA,KACD,CAAA;AAAA,EACH;AAEA,EAAA,MAAM,WAAW,GAAA,CAAI,aAAA;AAErB,EAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,IAAA;AAAA,EACF;AAEA,EAAA,GAAA,CAAI,aAAA,GAAgB,IAAI,KAAA,CAAM,QAAA,EAAU;AAAA,IACtC,MAAM,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAyB,IAAA,EAAmC;AAC9E,MAAA,MAAM,uBAAuB,OAAO,CAAA;AAEpC,MAAA,OAAO,OAAA,CAAQ,KAAA,CAAM,MAAA,EAAQ,OAAA,EAAS,IAAI,CAAA;AAAA,IAC5C;AAAA,GACD,CAAA;AACH;;;;"}
|