@sentry/cloudflare 11.12.0 → 11.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/dev/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/dev/baseSdk.js +98 -103
- package/build/cjs/dev/baseSdk.js.map +1 -1
- package/build/cjs/dev/client.js +218 -237
- package/build/cjs/dev/client.js.map +1 -1
- package/build/cjs/dev/clientCache.js +8 -8
- package/build/cjs/dev/clientCache.js.map +1 -1
- package/build/cjs/dev/debug-build.js +9 -5
- package/build/cjs/dev/debug-build.js.map +1 -1
- package/build/cjs/dev/defineCloudflareOptions.js +5 -8
- package/build/cjs/dev/defineCloudflareOptions.js.map +1 -1
- package/build/cjs/dev/durableobject.js +287 -176
- package/build/cjs/dev/durableobject.js.map +1 -1
- package/build/cjs/dev/flush.js +104 -77
- package/build/cjs/dev/flush.js.map +1 -1
- package/build/cjs/dev/index.js +181 -182
- package/build/cjs/dev/instrument.js +53 -39
- package/build/cjs/dev/instrument.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/index.js +34 -13
- package/build/cjs/dev/instrumentations/agents/index.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
- package/build/cjs/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
- package/build/cjs/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
- package/build/cjs/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/cjs/dev/instrumentations/agents/types.js +103 -58
- package/build/cjs/dev/instrumentations/agents/types.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -118
- package/build/cjs/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -44
- package/build/cjs/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js +70 -71
- package/build/cjs/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
- package/build/cjs/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentSqlStorage.js +50 -52
- package/build/cjs/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -123
- package/build/cjs/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentD1.js +131 -146
- package/build/cjs/dev/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentEmail.js +63 -61
- package/build/cjs/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentEnv.js +83 -88
- package/build/cjs/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentFetch.js +41 -48
- package/build/cjs/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js +25 -21
- package/build/cjs/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentKV.js +54 -67
- package/build/cjs/dev/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentQueue.js +98 -105
- package/build/cjs/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js +88 -94
- package/build/cjs/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentR2.js +128 -115
- package/build/cjs/dev/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js +90 -94
- package/build/cjs/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/cjs/dev/instrumentations/worker/instrumentTail.js +100 -55
- package/build/cjs/dev/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/cjs/dev/integrations/cronTriggers.js +130 -85
- package/build/cjs/dev/integrations/cronTriggers.js.map +1 -1
- package/build/cjs/dev/integrations/fetch.js +9 -9
- package/build/cjs/dev/integrations/fetch.js.map +1 -1
- package/build/cjs/dev/integrations/httpServer.js +41 -22
- package/build/cjs/dev/integrations/httpServer.js.map +1 -1
- package/build/cjs/dev/integrations/spotlight.js +52 -55
- package/build/cjs/dev/integrations/spotlight.js.map +1 -1
- package/build/cjs/dev/opentelemetry/tracer.js +10 -8
- package/build/cjs/dev/opentelemetry/tracer.js.map +1 -1
- package/build/cjs/dev/options.js +56 -39
- package/build/cjs/dev/options.js.map +1 -1
- package/build/cjs/dev/orchestrion-deferred-channels.js +45 -29
- package/build/cjs/dev/orchestrion-deferred-channels.js.map +1 -1
- package/build/cjs/dev/orchestrion-diagnostics-channel.js +97 -72
- package/build/cjs/dev/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/cjs/dev/pages-plugin.js +20 -21
- package/build/cjs/dev/pages-plugin.js.map +1 -1
- package/build/cjs/dev/request.js +16 -10
- package/build/cjs/dev/request.js.map +1 -1
- package/build/cjs/dev/scope-utils.js +12 -12
- package/build/cjs/dev/scope-utils.js.map +1 -1
- package/build/cjs/dev/sdk.js +24 -15
- package/build/cjs/dev/sdk.js.map +1 -1
- package/build/cjs/dev/transport.js +93 -86
- package/build/cjs/dev/transport.js.map +1 -1
- package/build/cjs/dev/utils/asyncContextStrategy.js +10 -10
- package/build/cjs/dev/utils/asyncContextStrategy.js.map +1 -1
- package/build/cjs/dev/utils/bindingPropagation.js +17 -11
- package/build/cjs/dev/utils/bindingPropagation.js.map +1 -1
- package/build/cjs/dev/utils/cloudflareTrace.js +34 -0
- package/build/cjs/dev/utils/cloudflareTrace.js.map +1 -0
- package/build/cjs/dev/utils/instrumentContext.js +74 -58
- package/build/cjs/dev/utils/instrumentContext.js.map +1 -1
- package/build/cjs/dev/utils/internalSqlQuery.js +38 -21
- package/build/cjs/dev/utils/internalSqlQuery.js.map +1 -1
- package/build/cjs/dev/utils/internalStorageKey.js +41 -38
- package/build/cjs/dev/utils/internalStorageKey.js.map +1 -1
- package/build/cjs/dev/utils/invocationContext.js +42 -32
- package/build/cjs/dev/utils/invocationContext.js.map +1 -1
- package/build/cjs/dev/utils/invocationScope.js +45 -21
- package/build/cjs/dev/utils/invocationScope.js.map +1 -1
- package/build/cjs/dev/utils/isBinding.js +47 -15
- package/build/cjs/dev/utils/isBinding.js.map +1 -1
- package/build/cjs/dev/utils/isCloudflareClass.js +11 -20
- package/build/cjs/dev/utils/isCloudflareClass.js.map +1 -1
- package/build/cjs/dev/utils/queueTraceMeta.js +24 -35
- package/build/cjs/dev/utils/queueTraceMeta.js.map +1 -1
- package/build/cjs/dev/utils/rpcMeta.js +37 -27
- package/build/cjs/dev/utils/rpcMeta.js.map +1 -1
- package/build/cjs/dev/utils/traceLinks.js +52 -42
- package/build/cjs/dev/utils/traceLinks.js.map +1 -1
- package/build/cjs/dev/vendor/stacktrace.js +32 -24
- package/build/cjs/dev/vendor/stacktrace.js.map +1 -1
- package/build/cjs/dev/vite/agentClass.js +105 -98
- package/build/cjs/dev/vite/agentClass.js.map +1 -1
- package/build/cjs/dev/vite/autoInstrument.js +125 -122
- package/build/cjs/dev/vite/autoInstrument.js.map +1 -1
- package/build/cjs/dev/vite/index.js +44 -21
- package/build/cjs/dev/vite/index.js.map +1 -1
- package/build/cjs/dev/vite/instrumentFile.js +37 -20
- package/build/cjs/dev/vite/instrumentFile.js.map +1 -1
- package/build/cjs/dev/vite/mastraObservability.js +19 -12
- package/build/cjs/dev/vite/mastraObservability.js.map +1 -1
- package/build/cjs/dev/vite/moduleShape.js +220 -201
- package/build/cjs/dev/vite/moduleShape.js.map +1 -1
- package/build/cjs/dev/vite/providedModulePlugin.js +62 -45
- package/build/cjs/dev/vite/providedModulePlugin.js.map +1 -1
- package/build/cjs/dev/vite/transform.js +332 -284
- package/build/cjs/dev/vite/transform.js.map +1 -1
- package/build/cjs/dev/vite/workerEntrypoint.js +66 -57
- package/build/cjs/dev/vite/workerEntrypoint.js.map +1 -1
- package/build/cjs/dev/vite/wranglerConfig.js +94 -67
- package/build/cjs/dev/vite/wranglerConfig.js.map +1 -1
- package/build/cjs/dev/withSentry.js +32 -26
- package/build/cjs/dev/withSentry.js.map +1 -1
- package/build/cjs/dev/workflows.js +164 -151
- package/build/cjs/dev/workflows.js.map +1 -1
- package/build/cjs/dev/wrapMethodWithSentry.js +148 -169
- package/build/cjs/dev/wrapMethodWithSentry.js.map +1 -1
- package/build/cjs/dev/wrapRequestHandlerWithInit.js +76 -78
- package/build/cjs/dev/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/cjs/prod/_virtual/_rolldown/runtime.js +22 -0
- package/build/cjs/prod/baseSdk.js +94 -93
- package/build/cjs/prod/baseSdk.js.map +1 -1
- package/build/cjs/prod/client.js +218 -237
- package/build/cjs/prod/client.js.map +1 -1
- package/build/cjs/prod/clientCache.js +8 -8
- package/build/cjs/prod/clientCache.js.map +1 -1
- package/build/cjs/prod/debug-build.js +9 -5
- package/build/cjs/prod/debug-build.js.map +1 -1
- package/build/cjs/prod/defineCloudflareOptions.js +5 -8
- package/build/cjs/prod/defineCloudflareOptions.js.map +1 -1
- package/build/cjs/prod/durableobject.js +287 -176
- package/build/cjs/prod/durableobject.js.map +1 -1
- package/build/cjs/prod/flush.js +104 -77
- package/build/cjs/prod/flush.js.map +1 -1
- package/build/cjs/prod/index.js +181 -182
- package/build/cjs/prod/instrument.js +53 -39
- package/build/cjs/prod/instrument.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/index.js +34 -13
- package/build/cjs/prod/instrumentations/agents/index.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -49
- package/build/cjs/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -16
- package/build/cjs/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -28
- package/build/cjs/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/cjs/prod/instrumentations/agents/types.js +103 -58
- package/build/cjs/prod/instrumentations/agents/types.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -118
- package/build/cjs/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -44
- package/build/cjs/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js +70 -71
- package/build/cjs/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -39
- package/build/cjs/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js +50 -52
- package/build/cjs/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -123
- package/build/cjs/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js +131 -146
- package/build/cjs/prod/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js +63 -61
- package/build/cjs/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js +83 -88
- package/build/cjs/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js +41 -48
- package/build/cjs/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js +25 -21
- package/build/cjs/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentKV.js +54 -67
- package/build/cjs/prod/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js +98 -105
- package/build/cjs/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js +88 -94
- package/build/cjs/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js +128 -115
- package/build/cjs/prod/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js +90 -94
- package/build/cjs/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js +100 -55
- package/build/cjs/prod/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/cjs/prod/integrations/cronTriggers.js +130 -85
- package/build/cjs/prod/integrations/cronTriggers.js.map +1 -1
- package/build/cjs/prod/integrations/fetch.js +9 -9
- package/build/cjs/prod/integrations/fetch.js.map +1 -1
- package/build/cjs/prod/integrations/httpServer.js +41 -22
- package/build/cjs/prod/integrations/httpServer.js.map +1 -1
- package/build/cjs/prod/integrations/spotlight.js +52 -55
- package/build/cjs/prod/integrations/spotlight.js.map +1 -1
- package/build/cjs/prod/opentelemetry/tracer.js +10 -8
- package/build/cjs/prod/opentelemetry/tracer.js.map +1 -1
- package/build/cjs/prod/options.js +38 -24
- package/build/cjs/prod/options.js.map +1 -1
- package/build/cjs/prod/orchestrion-deferred-channels.js +45 -29
- package/build/cjs/prod/orchestrion-deferred-channels.js.map +1 -1
- package/build/cjs/prod/orchestrion-diagnostics-channel.js +97 -72
- package/build/cjs/prod/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/cjs/prod/pages-plugin.js +20 -21
- package/build/cjs/prod/pages-plugin.js.map +1 -1
- package/build/cjs/prod/request.js +16 -10
- package/build/cjs/prod/request.js.map +1 -1
- package/build/cjs/prod/scope-utils.js +12 -12
- package/build/cjs/prod/scope-utils.js.map +1 -1
- package/build/cjs/prod/sdk.js +24 -15
- package/build/cjs/prod/sdk.js.map +1 -1
- package/build/cjs/prod/transport.js +93 -86
- package/build/cjs/prod/transport.js.map +1 -1
- package/build/cjs/prod/utils/asyncContextStrategy.js +10 -10
- package/build/cjs/prod/utils/asyncContextStrategy.js.map +1 -1
- package/build/cjs/prod/utils/bindingPropagation.js +17 -11
- package/build/cjs/prod/utils/bindingPropagation.js.map +1 -1
- package/build/cjs/prod/utils/cloudflareTrace.js +34 -0
- package/build/cjs/prod/utils/cloudflareTrace.js.map +1 -0
- package/build/cjs/prod/utils/instrumentContext.js +74 -58
- package/build/cjs/prod/utils/instrumentContext.js.map +1 -1
- package/build/cjs/prod/utils/internalSqlQuery.js +38 -21
- package/build/cjs/prod/utils/internalSqlQuery.js.map +1 -1
- package/build/cjs/prod/utils/internalStorageKey.js +41 -38
- package/build/cjs/prod/utils/internalStorageKey.js.map +1 -1
- package/build/cjs/prod/utils/invocationContext.js +42 -32
- package/build/cjs/prod/utils/invocationContext.js.map +1 -1
- package/build/cjs/prod/utils/invocationScope.js +45 -21
- package/build/cjs/prod/utils/invocationScope.js.map +1 -1
- package/build/cjs/prod/utils/isBinding.js +47 -15
- package/build/cjs/prod/utils/isBinding.js.map +1 -1
- package/build/cjs/prod/utils/isCloudflareClass.js +11 -20
- package/build/cjs/prod/utils/isCloudflareClass.js.map +1 -1
- package/build/cjs/prod/utils/queueTraceMeta.js +24 -35
- package/build/cjs/prod/utils/queueTraceMeta.js.map +1 -1
- package/build/cjs/prod/utils/rpcMeta.js +37 -27
- package/build/cjs/prod/utils/rpcMeta.js.map +1 -1
- package/build/cjs/prod/utils/traceLinks.js +52 -42
- package/build/cjs/prod/utils/traceLinks.js.map +1 -1
- package/build/cjs/prod/vendor/stacktrace.js +32 -24
- package/build/cjs/prod/vendor/stacktrace.js.map +1 -1
- package/build/cjs/prod/vite/agentClass.js +105 -98
- package/build/cjs/prod/vite/agentClass.js.map +1 -1
- package/build/cjs/prod/vite/autoInstrument.js +125 -122
- package/build/cjs/prod/vite/autoInstrument.js.map +1 -1
- package/build/cjs/prod/vite/index.js +44 -21
- package/build/cjs/prod/vite/index.js.map +1 -1
- package/build/cjs/prod/vite/instrumentFile.js +37 -20
- package/build/cjs/prod/vite/instrumentFile.js.map +1 -1
- package/build/cjs/prod/vite/mastraObservability.js +19 -12
- package/build/cjs/prod/vite/mastraObservability.js.map +1 -1
- package/build/cjs/prod/vite/moduleShape.js +220 -201
- package/build/cjs/prod/vite/moduleShape.js.map +1 -1
- package/build/cjs/prod/vite/providedModulePlugin.js +62 -45
- package/build/cjs/prod/vite/providedModulePlugin.js.map +1 -1
- package/build/cjs/prod/vite/transform.js +332 -284
- package/build/cjs/prod/vite/transform.js.map +1 -1
- package/build/cjs/prod/vite/workerEntrypoint.js +66 -57
- package/build/cjs/prod/vite/workerEntrypoint.js.map +1 -1
- package/build/cjs/prod/vite/wranglerConfig.js +94 -67
- package/build/cjs/prod/vite/wranglerConfig.js.map +1 -1
- package/build/cjs/prod/withSentry.js +32 -26
- package/build/cjs/prod/withSentry.js.map +1 -1
- package/build/cjs/prod/workflows.js +164 -151
- package/build/cjs/prod/workflows.js.map +1 -1
- package/build/cjs/prod/wrapMethodWithSentry.js +148 -169
- package/build/cjs/prod/wrapMethodWithSentry.js.map +1 -1
- package/build/cjs/prod/wrapRequestHandlerWithInit.js +76 -78
- package/build/cjs/prod/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/esm/dev/baseSdk.js +98 -101
- package/build/esm/dev/baseSdk.js.map +1 -1
- package/build/esm/dev/client.js +218 -235
- package/build/esm/dev/client.js.map +1 -1
- package/build/esm/dev/clientCache.js +8 -6
- package/build/esm/dev/clientCache.js.map +1 -1
- package/build/esm/dev/debug-build.js +9 -3
- package/build/esm/dev/debug-build.js.map +1 -1
- package/build/esm/dev/defineCloudflareOptions.js +5 -6
- package/build/esm/dev/defineCloudflareOptions.js.map +1 -1
- package/build/esm/dev/durableobject.js +287 -174
- package/build/esm/dev/durableobject.js.map +1 -1
- package/build/esm/dev/flush.js +104 -75
- package/build/esm/dev/flush.js.map +1 -1
- package/build/esm/dev/index.js +19 -18
- package/build/esm/dev/instrument.js +53 -37
- package/build/esm/dev/instrument.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/index.js +34 -11
- package/build/esm/dev/instrumentations/agents/index.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
- package/build/esm/dev/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
- package/build/esm/dev/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
- package/build/esm/dev/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/esm/dev/instrumentations/agents/types.js +103 -56
- package/build/esm/dev/instrumentations/agents/types.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js +87 -116
- package/build/esm/dev/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js +46 -42
- package/build/esm/dev/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js +70 -69
- package/build/esm/dev/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
- package/build/esm/dev/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentSqlStorage.js +50 -50
- package/build/esm/dev/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js +136 -121
- package/build/esm/dev/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentD1.js +131 -144
- package/build/esm/dev/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentEmail.js +63 -59
- package/build/esm/dev/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentEnv.js +83 -86
- package/build/esm/dev/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentFetch.js +41 -46
- package/build/esm/dev/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentFetcher.js +25 -19
- package/build/esm/dev/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentKV.js +54 -65
- package/build/esm/dev/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentQueue.js +98 -103
- package/build/esm/dev/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js +88 -92
- package/build/esm/dev/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentR2.js +128 -113
- package/build/esm/dev/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentScheduled.js +90 -92
- package/build/esm/dev/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/esm/dev/instrumentations/worker/instrumentTail.js +100 -53
- package/build/esm/dev/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/esm/dev/integrations/cronTriggers.js +129 -82
- package/build/esm/dev/integrations/cronTriggers.js.map +1 -1
- package/build/esm/dev/integrations/fetch.js +9 -6
- package/build/esm/dev/integrations/fetch.js.map +1 -1
- package/build/esm/dev/integrations/httpServer.js +40 -19
- package/build/esm/dev/integrations/httpServer.js.map +1 -1
- package/build/esm/dev/integrations/spotlight.js +51 -52
- package/build/esm/dev/integrations/spotlight.js.map +1 -1
- package/build/esm/dev/opentelemetry/tracer.js +10 -6
- package/build/esm/dev/opentelemetry/tracer.js.map +1 -1
- package/build/esm/dev/options.js +56 -37
- package/build/esm/dev/options.js.map +1 -1
- package/build/esm/dev/orchestrion-deferred-channels.js +45 -27
- package/build/esm/dev/orchestrion-deferred-channels.js.map +1 -1
- package/build/esm/dev/orchestrion-diagnostics-channel.js +87 -66
- package/build/esm/dev/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/esm/dev/package.json +1 -1
- package/build/esm/dev/pages-plugin.js +20 -19
- package/build/esm/dev/pages-plugin.js.map +1 -1
- package/build/esm/dev/request.js +14 -7
- package/build/esm/dev/request.js.map +1 -1
- package/build/esm/dev/scope-utils.js +12 -10
- package/build/esm/dev/scope-utils.js.map +1 -1
- package/build/esm/dev/sdk.js +23 -13
- package/build/esm/dev/sdk.js.map +1 -1
- package/build/esm/dev/transport.js +93 -84
- package/build/esm/dev/transport.js.map +1 -1
- package/build/esm/dev/utils/asyncContextStrategy.js +10 -8
- package/build/esm/dev/utils/asyncContextStrategy.js.map +1 -1
- package/build/esm/dev/utils/bindingPropagation.js +17 -9
- package/build/esm/dev/utils/bindingPropagation.js.map +1 -1
- package/build/esm/dev/utils/cloudflareTrace.js +34 -0
- package/build/esm/dev/utils/cloudflareTrace.js.map +1 -0
- package/build/esm/dev/utils/instrumentContext.js +74 -56
- package/build/esm/dev/utils/instrumentContext.js.map +1 -1
- package/build/esm/dev/utils/internalSqlQuery.js +38 -19
- package/build/esm/dev/utils/internalSqlQuery.js.map +1 -1
- package/build/esm/dev/utils/internalStorageKey.js +41 -36
- package/build/esm/dev/utils/internalStorageKey.js.map +1 -1
- package/build/esm/dev/utils/invocationContext.js +42 -30
- package/build/esm/dev/utils/invocationContext.js.map +1 -1
- package/build/esm/dev/utils/invocationScope.js +45 -19
- package/build/esm/dev/utils/invocationScope.js.map +1 -1
- package/build/esm/dev/utils/isBinding.js +47 -13
- package/build/esm/dev/utils/isBinding.js.map +1 -1
- package/build/esm/dev/utils/isCloudflareClass.js +11 -18
- package/build/esm/dev/utils/isCloudflareClass.js.map +1 -1
- package/build/esm/dev/utils/queueTraceMeta.js +24 -33
- package/build/esm/dev/utils/queueTraceMeta.js.map +1 -1
- package/build/esm/dev/utils/rpcMeta.js +37 -25
- package/build/esm/dev/utils/rpcMeta.js.map +1 -1
- package/build/esm/dev/utils/traceLinks.js +52 -40
- package/build/esm/dev/utils/traceLinks.js.map +1 -1
- package/build/esm/dev/vendor/stacktrace.js +31 -21
- package/build/esm/dev/vendor/stacktrace.js.map +1 -1
- package/build/esm/dev/vite/agentClass.js +105 -96
- package/build/esm/dev/vite/agentClass.js.map +1 -1
- package/build/esm/dev/vite/autoInstrument.js +125 -120
- package/build/esm/dev/vite/autoInstrument.js.map +1 -1
- package/build/esm/dev/vite/index.js +43 -19
- package/build/esm/dev/vite/index.js.map +1 -1
- package/build/esm/dev/vite/instrumentFile.js +37 -18
- package/build/esm/dev/vite/instrumentFile.js.map +1 -1
- package/build/esm/dev/vite/mastraObservability.js +19 -10
- package/build/esm/dev/vite/mastraObservability.js.map +1 -1
- package/build/esm/dev/vite/moduleShape.js +220 -199
- package/build/esm/dev/vite/moduleShape.js.map +1 -1
- package/build/esm/dev/vite/providedModulePlugin.js +60 -43
- package/build/esm/dev/vite/providedModulePlugin.js.map +1 -1
- package/build/esm/dev/vite/transform.js +330 -282
- package/build/esm/dev/vite/transform.js.map +1 -1
- package/build/esm/dev/vite/workerEntrypoint.js +66 -55
- package/build/esm/dev/vite/workerEntrypoint.js.map +1 -1
- package/build/esm/dev/vite/wranglerConfig.js +94 -65
- package/build/esm/dev/vite/wranglerConfig.js.map +1 -1
- package/build/esm/dev/withSentry.js +32 -24
- package/build/esm/dev/withSentry.js.map +1 -1
- package/build/esm/dev/workflows.js +164 -149
- package/build/esm/dev/workflows.js.map +1 -1
- package/build/esm/dev/wrapMethodWithSentry.js +148 -167
- package/build/esm/dev/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/dev/wrapRequestHandlerWithInit.js +76 -76
- package/build/esm/dev/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/esm/prod/baseSdk.js +94 -91
- package/build/esm/prod/baseSdk.js.map +1 -1
- package/build/esm/prod/client.js +218 -235
- package/build/esm/prod/client.js.map +1 -1
- package/build/esm/prod/clientCache.js +8 -6
- package/build/esm/prod/clientCache.js.map +1 -1
- package/build/esm/prod/debug-build.js +9 -3
- package/build/esm/prod/debug-build.js.map +1 -1
- package/build/esm/prod/defineCloudflareOptions.js +5 -6
- package/build/esm/prod/defineCloudflareOptions.js.map +1 -1
- package/build/esm/prod/durableobject.js +287 -174
- package/build/esm/prod/durableobject.js.map +1 -1
- package/build/esm/prod/flush.js +104 -75
- package/build/esm/prod/flush.js.map +1 -1
- package/build/esm/prod/index.js +19 -18
- package/build/esm/prod/instrument.js +53 -37
- package/build/esm/prod/instrument.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/index.js +34 -11
- package/build/esm/prod/instrumentations/agents/index.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js +46 -47
- package/build/esm/prod/instrumentations/agents/instrumentAgentCallableRpc.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js +23 -14
- package/build/esm/prod/instrumentations/agents/instrumentAgentRequestConversation.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js +36 -26
- package/build/esm/prod/instrumentations/agents/instrumentChatAgentConversation.js.map +1 -1
- package/build/esm/prod/instrumentations/agents/types.js +103 -56
- package/build/esm/prod/instrumentations/agents/types.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js +87 -116
- package/build/esm/prod/instrumentations/instrumentDurableObjectHandlers.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js +46 -42
- package/build/esm/prod/instrumentations/instrumentDurableObjectNamespace.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js +70 -69
- package/build/esm/prod/instrumentations/instrumentDurableObjectStorage.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js +31 -37
- package/build/esm/prod/instrumentations/instrumentDurableObjectSyncKvStorage.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js +50 -50
- package/build/esm/prod/instrumentations/instrumentSqlStorage.js.map +1 -1
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js +136 -121
- package/build/esm/prod/instrumentations/instrumentWorkerEntrypoint.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentD1.js +131 -144
- package/build/esm/prod/instrumentations/worker/instrumentD1.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js +63 -59
- package/build/esm/prod/instrumentations/worker/instrumentEmail.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js +83 -86
- package/build/esm/prod/instrumentations/worker/instrumentEnv.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js +41 -46
- package/build/esm/prod/instrumentations/worker/instrumentFetch.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js +25 -19
- package/build/esm/prod/instrumentations/worker/instrumentFetcher.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentKV.js +54 -65
- package/build/esm/prod/instrumentations/worker/instrumentKV.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js +98 -103
- package/build/esm/prod/instrumentations/worker/instrumentQueue.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js +88 -92
- package/build/esm/prod/instrumentations/worker/instrumentQueueProducer.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentR2.js +128 -113
- package/build/esm/prod/instrumentations/worker/instrumentR2.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js +90 -92
- package/build/esm/prod/instrumentations/worker/instrumentScheduled.js.map +1 -1
- package/build/esm/prod/instrumentations/worker/instrumentTail.js +100 -53
- package/build/esm/prod/instrumentations/worker/instrumentTail.js.map +1 -1
- package/build/esm/prod/integrations/cronTriggers.js +129 -82
- package/build/esm/prod/integrations/cronTriggers.js.map +1 -1
- package/build/esm/prod/integrations/fetch.js +9 -6
- package/build/esm/prod/integrations/fetch.js.map +1 -1
- package/build/esm/prod/integrations/httpServer.js +40 -19
- package/build/esm/prod/integrations/httpServer.js.map +1 -1
- package/build/esm/prod/integrations/spotlight.js +51 -52
- package/build/esm/prod/integrations/spotlight.js.map +1 -1
- package/build/esm/prod/opentelemetry/tracer.js +10 -6
- package/build/esm/prod/opentelemetry/tracer.js.map +1 -1
- package/build/esm/prod/options.js +38 -22
- package/build/esm/prod/options.js.map +1 -1
- package/build/esm/prod/orchestrion-deferred-channels.js +45 -27
- package/build/esm/prod/orchestrion-deferred-channels.js.map +1 -1
- package/build/esm/prod/orchestrion-diagnostics-channel.js +87 -66
- package/build/esm/prod/orchestrion-diagnostics-channel.js.map +1 -1
- package/build/esm/prod/package.json +1 -1
- package/build/esm/prod/pages-plugin.js +20 -19
- package/build/esm/prod/pages-plugin.js.map +1 -1
- package/build/esm/prod/request.js +14 -7
- package/build/esm/prod/request.js.map +1 -1
- package/build/esm/prod/scope-utils.js +12 -10
- package/build/esm/prod/scope-utils.js.map +1 -1
- package/build/esm/prod/sdk.js +23 -13
- package/build/esm/prod/sdk.js.map +1 -1
- package/build/esm/prod/transport.js +93 -84
- package/build/esm/prod/transport.js.map +1 -1
- package/build/esm/prod/utils/asyncContextStrategy.js +10 -8
- package/build/esm/prod/utils/asyncContextStrategy.js.map +1 -1
- package/build/esm/prod/utils/bindingPropagation.js +17 -9
- package/build/esm/prod/utils/bindingPropagation.js.map +1 -1
- package/build/esm/prod/utils/cloudflareTrace.js +34 -0
- package/build/esm/prod/utils/cloudflareTrace.js.map +1 -0
- package/build/esm/prod/utils/instrumentContext.js +74 -56
- package/build/esm/prod/utils/instrumentContext.js.map +1 -1
- package/build/esm/prod/utils/internalSqlQuery.js +38 -19
- package/build/esm/prod/utils/internalSqlQuery.js.map +1 -1
- package/build/esm/prod/utils/internalStorageKey.js +41 -36
- package/build/esm/prod/utils/internalStorageKey.js.map +1 -1
- package/build/esm/prod/utils/invocationContext.js +42 -30
- package/build/esm/prod/utils/invocationContext.js.map +1 -1
- package/build/esm/prod/utils/invocationScope.js +45 -19
- package/build/esm/prod/utils/invocationScope.js.map +1 -1
- package/build/esm/prod/utils/isBinding.js +47 -13
- package/build/esm/prod/utils/isBinding.js.map +1 -1
- package/build/esm/prod/utils/isCloudflareClass.js +11 -18
- package/build/esm/prod/utils/isCloudflareClass.js.map +1 -1
- package/build/esm/prod/utils/queueTraceMeta.js +24 -33
- package/build/esm/prod/utils/queueTraceMeta.js.map +1 -1
- package/build/esm/prod/utils/rpcMeta.js +37 -25
- package/build/esm/prod/utils/rpcMeta.js.map +1 -1
- package/build/esm/prod/utils/traceLinks.js +52 -40
- package/build/esm/prod/utils/traceLinks.js.map +1 -1
- package/build/esm/prod/vendor/stacktrace.js +31 -21
- package/build/esm/prod/vendor/stacktrace.js.map +1 -1
- package/build/esm/prod/vite/agentClass.js +105 -96
- package/build/esm/prod/vite/agentClass.js.map +1 -1
- package/build/esm/prod/vite/autoInstrument.js +125 -120
- package/build/esm/prod/vite/autoInstrument.js.map +1 -1
- package/build/esm/prod/vite/index.js +43 -19
- package/build/esm/prod/vite/index.js.map +1 -1
- package/build/esm/prod/vite/instrumentFile.js +37 -18
- package/build/esm/prod/vite/instrumentFile.js.map +1 -1
- package/build/esm/prod/vite/mastraObservability.js +19 -10
- package/build/esm/prod/vite/mastraObservability.js.map +1 -1
- package/build/esm/prod/vite/moduleShape.js +220 -199
- package/build/esm/prod/vite/moduleShape.js.map +1 -1
- package/build/esm/prod/vite/providedModulePlugin.js +60 -43
- package/build/esm/prod/vite/providedModulePlugin.js.map +1 -1
- package/build/esm/prod/vite/transform.js +330 -282
- package/build/esm/prod/vite/transform.js.map +1 -1
- package/build/esm/prod/vite/workerEntrypoint.js +66 -55
- package/build/esm/prod/vite/workerEntrypoint.js.map +1 -1
- package/build/esm/prod/vite/wranglerConfig.js +94 -65
- package/build/esm/prod/vite/wranglerConfig.js.map +1 -1
- package/build/esm/prod/withSentry.js +32 -24
- package/build/esm/prod/withSentry.js.map +1 -1
- package/build/esm/prod/workflows.js +164 -149
- package/build/esm/prod/workflows.js.map +1 -1
- package/build/esm/prod/wrapMethodWithSentry.js +148 -167
- package/build/esm/prod/wrapMethodWithSentry.js.map +1 -1
- package/build/esm/prod/wrapRequestHandlerWithInit.js +76 -76
- package/build/esm/prod/wrapRequestHandlerWithInit.js.map +1 -1
- package/build/types/baseSdk.d.ts.map +1 -1
- package/build/types/client.d.ts +9 -1
- package/build/types/client.d.ts.map +1 -1
- package/build/types/durableobject.d.ts.map +1 -1
- package/build/types/index.d.ts +3 -2
- package/build/types/index.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentEmail.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentFetcher.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentQueue.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentScheduled.d.ts.map +1 -1
- package/build/types/instrumentations/worker/instrumentTail.d.ts +4 -2
- package/build/types/instrumentations/worker/instrumentTail.d.ts.map +1 -1
- package/build/types/options.d.ts.map +1 -1
- package/build/types/utils/cloudflareTrace.d.ts +13 -0
- package/build/types/utils/cloudflareTrace.d.ts.map +1 -0
- package/build/types/vite/autoInstrument.d.ts.map +1 -1
- package/build/types/vite/index.d.ts +3 -0
- package/build/types/vite/index.d.ts.map +1 -1
- package/build/types/vite/providedModulePlugin.d.ts +15 -11
- package/build/types/vite/providedModulePlugin.d.ts.map +1 -1
- package/build/types/vite/transform.d.ts +12 -2
- package/build/types/vite/transform.d.ts.map +1 -1
- package/build/types/vite/wranglerConfig.d.ts +8 -0
- package/build/types/vite/wranglerConfig.d.ts.map +1 -1
- package/build/types/workflows.d.ts.map +1 -1
- package/build/types/wrapMethodWithSentry.d.ts.map +1 -1
- package/build/types/wrapRequestHandlerWithInit.d.ts.map +1 -1
- package/package.json +10 -14
- package/build/cjs/dev/index.js.map +0 -1
- package/build/cjs/dev/vite/flueRuntime.js +0 -15
- package/build/cjs/dev/vite/flueRuntime.js.map +0 -1
- package/build/cjs/prod/index.js.map +0 -1
- package/build/cjs/prod/vite/flueRuntime.js +0 -15
- package/build/cjs/prod/vite/flueRuntime.js.map +0 -1
- package/build/esm/dev/index.js.map +0 -1
- package/build/esm/dev/vite/flueRuntime.js +0 -13
- package/build/esm/dev/vite/flueRuntime.js.map +0 -1
- package/build/esm/prod/index.js.map +0 -1
- package/build/esm/prod/vite/flueRuntime.js +0 -13
- package/build/esm/prod/vite/flueRuntime.js.map +0 -1
- package/build/types/vite/flueRuntime.d.ts +0 -12
- package/build/types/vite/flueRuntime.d.ts.map +0 -1
|
@@ -1,28 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const invocationContext = require('./invocationContext.js');
|
|
5
|
-
|
|
1
|
+
const require_invocationContext = require("./invocationContext.js");
|
|
2
|
+
let _sentry_core = require("@sentry/core");
|
|
3
|
+
// src/utils/invocationScope.ts
|
|
6
4
|
const constructionScopes = /* @__PURE__ */ new WeakSet();
|
|
5
|
+
/**
|
|
6
|
+
* Runs a Durable Object constructor on a forked isolation scope.
|
|
7
|
+
*
|
|
8
|
+
* Async work the constructor starts, such as a `blockConcurrencyWhile` callback, runs after the RPC
|
|
9
|
+
* wrappers are installed and inherits this scope, so the calls it makes to the instance's own methods
|
|
10
|
+
* are not treated as incoming RPC calls. The scope is not an invocation: it has no invocation state,
|
|
11
|
+
* and an instrumented handler that this work calls still forks a scope of its own.
|
|
12
|
+
*/
|
|
7
13
|
function withConstructionIsolationScope(callback) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return callback();
|
|
14
|
-
});
|
|
14
|
+
if ((0, _sentry_core.getIsolationScope)() !== (0, _sentry_core.getDefaultIsolationScope)()) return callback();
|
|
15
|
+
return (0, _sentry_core.withIsolationScope)((scope) => {
|
|
16
|
+
constructionScopes.add(scope);
|
|
17
|
+
return callback();
|
|
18
|
+
});
|
|
15
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Runs `callback` on the isolation scope for the current invocation.
|
|
22
|
+
*
|
|
23
|
+
* An instrumented handler is either the entry point of an invocation or reentrant — reached from
|
|
24
|
+
* another instrumented handler already serving the same invocation (a Durable Object method calling
|
|
25
|
+
* its own `fetch`, an RPC method reaching a sibling method). Only the entry point may fork:
|
|
26
|
+
*
|
|
27
|
+
* - Forking at the entry point is mandatory. `setUser`/`setTag` write to the isolation scope, and a
|
|
28
|
+
* Durable Object's isolation scope outlives the invocation that touched it, so without a fork one
|
|
29
|
+
* invocation's user and tags reappear on the next invocation's events in the same isolate.
|
|
30
|
+
* Forking clones, so request data set by an enclosing wrapper is still inherited.
|
|
31
|
+
* - Forking again when reentrant would be wrong. Everything below the entry point is one logical
|
|
32
|
+
* unit of work: a nested call must see what the caller set and be able to add to it, the way it
|
|
33
|
+
* would if the SDK were not wrapping it at all.
|
|
34
|
+
*
|
|
35
|
+
* The AsyncLocalStorage strategy hands the default isolation scope back whenever no invocation is in
|
|
36
|
+
* flight, and a forked one while inside `withIsolationScope`. Reference-comparing against the default
|
|
37
|
+
* and the construction scopes (see {@link withConstructionIsolationScope}) is therefore enough to tell
|
|
38
|
+
* the two cases apart. The stack fallback does not fork, so it reports the default scope even inside an
|
|
39
|
+
* invocation; there the fork degrades to a no-op, which the stack strategy tolerates. This matches the
|
|
40
|
+
* approach used by `patchEventHandler` in Nuxt.
|
|
41
|
+
*/
|
|
16
42
|
function withInvocationIsolationScope(callback, context) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
return core.withIsolationScope(newIsolationScope, () => callback(newIsolationScope));
|
|
43
|
+
const isolationScope = (0, _sentry_core.getIsolationScope)();
|
|
44
|
+
const isEntryPoint = isolationScope === (0, _sentry_core.getDefaultIsolationScope)() || constructionScopes.has(isolationScope);
|
|
45
|
+
const newIsolationScope = isEntryPoint ? isolationScope.clone() : isolationScope;
|
|
46
|
+
if (isEntryPoint) require_invocationContext.setInvocationState(newIsolationScope, { ctx: context });
|
|
47
|
+
return (0, _sentry_core.withIsolationScope)(newIsolationScope, () => callback(newIsolationScope));
|
|
24
48
|
}
|
|
25
|
-
|
|
26
49
|
exports.withConstructionIsolationScope = withConstructionIsolationScope;
|
|
27
50
|
exports.withInvocationIsolationScope = withInvocationIsolationScope;
|
|
28
|
-
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=invocationScope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invocationScope.js","sources":["../../../../src/utils/invocationScope.ts"],"sourcesContent":["import { getDefaultIsolationScope, getIsolationScope, type Scope, withIsolationScope } from '@sentry/core';\nimport type { ExecutionContextCompat } from '../executionContext';\nimport { setInvocationState } from './invocationContext';\n\nconst constructionScopes = new WeakSet<Scope>();\n\n/**\n * Runs a Durable Object constructor on a forked isolation scope.\n *\n * Async work the constructor starts, such as a `blockConcurrencyWhile` callback, runs after the RPC\n * wrappers are installed and inherits this scope, so the calls it makes to the instance's own methods\n * are not treated as incoming RPC calls. The scope is not an invocation: it has no invocation state,\n * and an instrumented handler that this work calls still forks a scope of its own.\n */\nexport function withConstructionIsolationScope<T>(callback: () => T): T {\n if (getIsolationScope() !== getDefaultIsolationScope()) {\n return callback();\n }\n\n return withIsolationScope(scope => {\n constructionScopes.add(scope);\n return callback();\n });\n}\n\n/**\n * Runs `callback` on the isolation scope for the current invocation.\n *\n * An instrumented handler is either the entry point of an invocation or reentrant — reached from\n * another instrumented handler already serving the same invocation (a Durable Object method calling\n * its own `fetch`, an RPC method reaching a sibling method). Only the entry point may fork:\n *\n * - Forking at the entry point is mandatory. `setUser`/`setTag` write to the isolation scope, and a\n * Durable Object's isolation scope outlives the invocation that touched it, so without a fork one\n * invocation's user and tags reappear on the next invocation's events in the same isolate.\n * Forking clones, so request data set by an enclosing wrapper is still inherited.\n * - Forking again when reentrant would be wrong. Everything below the entry point is one logical\n * unit of work: a nested call must see what the caller set and be able to add to it, the way it\n * would if the SDK were not wrapping it at all.\n *\n * The AsyncLocalStorage strategy hands the default isolation scope back whenever no invocation is in\n * flight, and a forked one while inside `withIsolationScope`. Reference-comparing against the default\n * and the construction scopes (see {@link withConstructionIsolationScope}) is therefore enough to tell\n * the two cases apart. The stack fallback does not fork, so it reports the default scope even inside an\n * invocation; there the fork degrades to a no-op, which the stack strategy tolerates. This matches the\n * approach used by `patchEventHandler` in Nuxt.\n */\nexport function withInvocationIsolationScope<T>(callback: (scope: Scope) => T, context?: ExecutionContextCompat): T {\n const isolationScope = getIsolationScope();\n\n const isEntryPoint = isolationScope === getDefaultIsolationScope() || constructionScopes.has(isolationScope);\n const newIsolationScope = isEntryPoint ? isolationScope.clone() : isolationScope;\n\n if (isEntryPoint) {\n setInvocationState(newIsolationScope, { ctx: context });\n }\n\n return withIsolationScope(newIsolationScope, () => callback(newIsolationScope));\n}\n"],"
|
|
1
|
+
{"version":3,"file":"invocationScope.js","names":["getIsolationScope","getDefaultIsolationScope","withIsolationScope","setInvocationState"],"sources":["../../../../src/utils/invocationScope.ts"],"sourcesContent":["import { getDefaultIsolationScope, getIsolationScope, type Scope, withIsolationScope } from '@sentry/core';\nimport type { ExecutionContextCompat } from '../executionContext';\nimport { setInvocationState } from './invocationContext';\n\nconst constructionScopes = new WeakSet<Scope>();\n\n/**\n * Runs a Durable Object constructor on a forked isolation scope.\n *\n * Async work the constructor starts, such as a `blockConcurrencyWhile` callback, runs after the RPC\n * wrappers are installed and inherits this scope, so the calls it makes to the instance's own methods\n * are not treated as incoming RPC calls. The scope is not an invocation: it has no invocation state,\n * and an instrumented handler that this work calls still forks a scope of its own.\n */\nexport function withConstructionIsolationScope<T>(callback: () => T): T {\n if (getIsolationScope() !== getDefaultIsolationScope()) {\n return callback();\n }\n\n return withIsolationScope(scope => {\n constructionScopes.add(scope);\n return callback();\n });\n}\n\n/**\n * Runs `callback` on the isolation scope for the current invocation.\n *\n * An instrumented handler is either the entry point of an invocation or reentrant — reached from\n * another instrumented handler already serving the same invocation (a Durable Object method calling\n * its own `fetch`, an RPC method reaching a sibling method). Only the entry point may fork:\n *\n * - Forking at the entry point is mandatory. `setUser`/`setTag` write to the isolation scope, and a\n * Durable Object's isolation scope outlives the invocation that touched it, so without a fork one\n * invocation's user and tags reappear on the next invocation's events in the same isolate.\n * Forking clones, so request data set by an enclosing wrapper is still inherited.\n * - Forking again when reentrant would be wrong. Everything below the entry point is one logical\n * unit of work: a nested call must see what the caller set and be able to add to it, the way it\n * would if the SDK were not wrapping it at all.\n *\n * The AsyncLocalStorage strategy hands the default isolation scope back whenever no invocation is in\n * flight, and a forked one while inside `withIsolationScope`. Reference-comparing against the default\n * and the construction scopes (see {@link withConstructionIsolationScope}) is therefore enough to tell\n * the two cases apart. The stack fallback does not fork, so it reports the default scope even inside an\n * invocation; there the fork degrades to a no-op, which the stack strategy tolerates. This matches the\n * approach used by `patchEventHandler` in Nuxt.\n */\nexport function withInvocationIsolationScope<T>(callback: (scope: Scope) => T, context?: ExecutionContextCompat): T {\n const isolationScope = getIsolationScope();\n\n const isEntryPoint = isolationScope === getDefaultIsolationScope() || constructionScopes.has(isolationScope);\n const newIsolationScope = isEntryPoint ? isolationScope.clone() : isolationScope;\n\n if (isEntryPoint) {\n setInvocationState(newIsolationScope, { ctx: context });\n }\n\n return withIsolationScope(newIsolationScope, () => callback(newIsolationScope));\n}\n"],"mappings":";;;AAIA,MAAM,qCAAqB,IAAI,QAAe;;;;;;;;;AAU9C,SAAgB,+BAAkC,UAAsB;CACtE,KAAA,GAAIA,aAAAA,kBAAAA,CAAkB,OAAA,GAAMC,aAAAA,yBAAAA,CAAyB,GACnD,OAAO,SAAS;CAGlB,QAAA,GAAOC,aAAAA,mBAAAA,EAAmB,UAAS;EACjC,mBAAmB,IAAI,KAAK;EAC5B,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAgB,6BAAgC,UAA+B,SAAqC;CAClH,MAAM,kBAAA,GAAiBF,aAAAA,kBAAAA,CAAkB;CAEzC,MAAM,eAAe,oBAAA,GAAmBC,aAAAA,yBAAAA,CAAyB,KAAK,mBAAmB,IAAI,cAAc;CAC3G,MAAM,oBAAoB,eAAe,eAAe,MAAM,IAAI;CAElE,IAAI,cACFE,0BAAAA,mBAAmB,mBAAmB,EAAE,KAAK,QAAQ,CAAC;CAGxD,QAAA,GAAOD,aAAAA,mBAAAA,CAAmB,yBAAyB,SAAS,iBAAiB,CAAC;AAChF"}
|
|
@@ -1,32 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/utils/isBinding.ts
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is a JSRPC proxy (service binding).
|
|
4
|
+
*
|
|
5
|
+
* JSRPC proxies return a truthy value for ANY property access, including
|
|
6
|
+
* properties that don't exist. This makes other duck-type checks unreliable
|
|
7
|
+
* unless we exclude JSRPC first.
|
|
8
|
+
*
|
|
9
|
+
* Must be checked before other binding type checks.
|
|
10
|
+
*/
|
|
3
11
|
function isJSRPC(item) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
try {
|
|
13
|
+
return !!item[`__some_property_that_will_never_exist__${Math.random()}`];
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
9
17
|
}
|
|
10
18
|
const isNotJSRPC = (item) => !isJSRPC(item);
|
|
19
|
+
/**
|
|
20
|
+
* Duck-type check for DurableObjectNamespace bindings.
|
|
21
|
+
* DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.
|
|
22
|
+
*/
|
|
11
23
|
function isDurableObjectNamespace(item) {
|
|
12
|
-
|
|
24
|
+
return item != null && isNotJSRPC(item) && typeof item.idFromName === "function";
|
|
13
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Duck-type check for Queue producer bindings.
|
|
28
|
+
* Queue has `send` and `sendBatch` async methods.
|
|
29
|
+
*/
|
|
14
30
|
function isQueue(item) {
|
|
15
|
-
|
|
31
|
+
return item != null && isNotJSRPC(item) && typeof item.send === "function" && typeof item.sendBatch === "function";
|
|
16
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Duck-type check for D1Database bindings.
|
|
35
|
+
* D1Database has `prepare`, `batch`, and `exec` methods.
|
|
36
|
+
*/
|
|
17
37
|
function isD1Database(item) {
|
|
18
|
-
|
|
38
|
+
return item != null && isNotJSRPC(item) && typeof item.prepare === "function" && typeof item.batch === "function" && typeof item.exec === "function";
|
|
19
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Duck-type check for Workers AI bindings.
|
|
42
|
+
* The Ai binding has `run`, `gateway`, and `toMarkdown` methods.
|
|
43
|
+
*/
|
|
20
44
|
function isAiBinding(item) {
|
|
21
|
-
|
|
45
|
+
return item != null && isNotJSRPC(item) && typeof item.run === "function" && typeof item.gateway === "function" && typeof item.toMarkdown === "function";
|
|
22
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Duck-type check for Workers KV namespace bindings.
|
|
49
|
+
* KVNamespace has `get`, `put`, `list`, and `getWithMetadata` methods.
|
|
50
|
+
*/
|
|
23
51
|
function isKVNamespace(item) {
|
|
24
|
-
|
|
52
|
+
return item != null && isNotJSRPC(item) && typeof item.get === "function" && typeof item.put === "function" && typeof item.list === "function" && typeof item.getWithMetadata === "function";
|
|
25
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Duck-type check for R2 Bucket bindings.
|
|
56
|
+
* R2Bucket has `head`, `put`, and `createMultipartUpload` methods.
|
|
57
|
+
*/
|
|
26
58
|
function isR2Bucket(item) {
|
|
27
|
-
|
|
59
|
+
return item != null && isNotJSRPC(item) && typeof item.head === "function" && typeof item.put === "function" && typeof item.createMultipartUpload === "function";
|
|
28
60
|
}
|
|
29
|
-
|
|
30
61
|
exports.isAiBinding = isAiBinding;
|
|
31
62
|
exports.isD1Database = isD1Database;
|
|
32
63
|
exports.isDurableObjectNamespace = isDurableObjectNamespace;
|
|
@@ -34,4 +65,5 @@ exports.isJSRPC = isJSRPC;
|
|
|
34
65
|
exports.isKVNamespace = isKVNamespace;
|
|
35
66
|
exports.isQueue = isQueue;
|
|
36
67
|
exports.isR2Bucket = isR2Bucket;
|
|
37
|
-
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=isBinding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBinding.js","sources":["../../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { Ai, D1Database, DurableObjectNamespace, KVNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers AI bindings.\n * The Ai binding has `run`, `gateway`, and `toMarkdown` methods.\n */\nexport function isAiBinding(item: unknown): item is Ai {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.run === 'function' &&\n typeof item.gateway === 'function' &&\n typeof item.toMarkdown === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers KV namespace bindings.\n * KVNamespace has `get`, `put`, `list`, and `getWithMetadata` methods.\n */\nexport function isKVNamespace(item: unknown): item is KVNamespace {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.get === 'function' &&\n typeof item.put === 'function' &&\n typeof item.list === 'function' &&\n typeof item.getWithMetadata === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n"],"
|
|
1
|
+
{"version":3,"file":"isBinding.js","names":[],"sources":["../../../../src/utils/isBinding.ts"],"sourcesContent":["/**\n * Adapted from https://github.com/evanderkoogh/otel-cf-workers/blob/effeb549f0a4ed1c55ea0c4f0d8e8e37e5494fb3/src/instrumentation/env.ts\n *\n * BSD 3-Clause License\n *\n * Copyright (c) 2023, Erwin van der Koogh\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n *\n * 3. Neither the name of the copyright holder nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport type { Ai, D1Database, DurableObjectNamespace, KVNamespace, Queue, R2Bucket } from '@cloudflare/workers-types';\n\n/**\n * Checks if a value is a JSRPC proxy (service binding).\n *\n * JSRPC proxies return a truthy value for ANY property access, including\n * properties that don't exist. This makes other duck-type checks unreliable\n * unless we exclude JSRPC first.\n *\n * Must be checked before other binding type checks.\n */\nexport function isJSRPC(item: unknown): item is Service {\n try {\n return !!(item as Record<string, unknown>)[`__some_property_that_will_never_exist__${Math.random()}`];\n } catch {\n return false;\n }\n}\n\nconst isNotJSRPC = (item: unknown): item is Record<string, unknown> => !isJSRPC(item);\n\n/**\n * Duck-type check for DurableObjectNamespace bindings.\n * DurableObjectNamespace has `idFromName`, `idFromString`, `get`, `newUniqueId`.\n */\nexport function isDurableObjectNamespace(item: unknown): item is DurableObjectNamespace {\n return item != null && isNotJSRPC(item) && typeof item.idFromName === 'function';\n}\n\n/**\n * Duck-type check for Queue producer bindings.\n * Queue has `send` and `sendBatch` async methods.\n */\nexport function isQueue(item: unknown): item is Queue {\n return item != null && isNotJSRPC(item) && typeof item.send === 'function' && typeof item.sendBatch === 'function';\n}\n\n/**\n * Duck-type check for D1Database bindings.\n * D1Database has `prepare`, `batch`, and `exec` methods.\n */\nexport function isD1Database(item: unknown): item is D1Database {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.prepare === 'function' &&\n typeof item.batch === 'function' &&\n typeof item.exec === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers AI bindings.\n * The Ai binding has `run`, `gateway`, and `toMarkdown` methods.\n */\nexport function isAiBinding(item: unknown): item is Ai {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.run === 'function' &&\n typeof item.gateway === 'function' &&\n typeof item.toMarkdown === 'function'\n );\n}\n\n/**\n * Duck-type check for Workers KV namespace bindings.\n * KVNamespace has `get`, `put`, `list`, and `getWithMetadata` methods.\n */\nexport function isKVNamespace(item: unknown): item is KVNamespace {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.get === 'function' &&\n typeof item.put === 'function' &&\n typeof item.list === 'function' &&\n typeof item.getWithMetadata === 'function'\n );\n}\n\n/**\n * Duck-type check for R2 Bucket bindings.\n * R2Bucket has `head`, `put`, and `createMultipartUpload` methods.\n */\nexport function isR2Bucket(item: unknown): item is R2Bucket {\n return (\n item != null &&\n isNotJSRPC(item) &&\n typeof item.head === 'function' &&\n typeof item.put === 'function' &&\n typeof item.createMultipartUpload === 'function'\n );\n}\n"],"mappings":";;;;;;;;;;AA4CA,SAAgB,QAAQ,MAAgC;CACtD,IAAI;EACF,OAAO,CAAC,CAAE,KAAiC,0CAA0C,KAAK,OAAO;CACnG,QAAQ;EACN,OAAO;CACT;AACF;AAEA,MAAM,cAAc,SAAmD,CAAC,QAAQ,IAAI;;;;;AAMpF,SAAgB,yBAAyB,MAA+C;CACtF,OAAO,QAAQ,QAAQ,WAAW,IAAI,KAAK,OAAO,KAAK,eAAe;AACxE;;;;;AAMA,SAAgB,QAAQ,MAA8B;CACpD,OAAO,QAAQ,QAAQ,WAAW,IAAI,KAAK,OAAO,KAAK,SAAS,cAAc,OAAO,KAAK,cAAc;AAC1G;;;;;AAMA,SAAgB,aAAa,MAAmC;CAC9D,OACE,QAAQ,QACR,WAAW,IAAI,KACf,OAAO,KAAK,YAAY,cACxB,OAAO,KAAK,UAAU,cACtB,OAAO,KAAK,SAAS;AAEzB;;;;;AAMA,SAAgB,YAAY,MAA2B;CACrD,OACE,QAAQ,QACR,WAAW,IAAI,KACf,OAAO,KAAK,QAAQ,cACpB,OAAO,KAAK,YAAY,cACxB,OAAO,KAAK,eAAe;AAE/B;;;;;AAMA,SAAgB,cAAc,MAAoC;CAChE,OACE,QAAQ,QACR,WAAW,IAAI,KACf,OAAO,KAAK,QAAQ,cACpB,OAAO,KAAK,QAAQ,cACpB,OAAO,KAAK,SAAS,cACrB,OAAO,KAAK,oBAAoB;AAEpC;;;;;AAMA,SAAgB,WAAW,MAAiC;CAC1D,OACE,QAAQ,QACR,WAAW,IAAI,KACf,OAAO,KAAK,SAAS,cACrB,OAAO,KAAK,QAAQ,cACpB,OAAO,KAAK,0BAA0B;AAE1C"}
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// src/utils/isCloudflareClass.ts
|
|
3
2
|
function isCloudflareClass(value, className) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const ctor = proto.constructor;
|
|
13
|
-
const constructorName = ctor?.name;
|
|
14
|
-
if (constructorName === className) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
proto = Object.getPrototypeOf(proto);
|
|
18
|
-
}
|
|
19
|
-
return false;
|
|
3
|
+
if (!value || typeof value !== "function") return false;
|
|
4
|
+
if (value.name === className) return false;
|
|
5
|
+
let proto = value.prototype;
|
|
6
|
+
while (proto) {
|
|
7
|
+
if (proto.constructor?.name === className) return true;
|
|
8
|
+
proto = Object.getPrototypeOf(proto);
|
|
9
|
+
}
|
|
10
|
+
return false;
|
|
20
11
|
}
|
|
21
|
-
|
|
22
12
|
exports.isCloudflareClass = isCloudflareClass;
|
|
23
|
-
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=isCloudflareClass.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isCloudflareClass.js","sources":["../../../../src/utils/isCloudflareClass.ts"],"sourcesContent":["import type { DurableObject, WorkflowEntrypoint } from 'cloudflare:workers';\nimport type { WorkerEntrypointConstructor } from '../instrumentations/instrumentWorkerEntrypoint';\ntype CloudflareClassName = 'WorkerEntrypoint' | 'DurableObject' | 'WorkflowEntrypoint';\n\n/**\n * Checks if a class constructor extends a specific Cloudflare base class.\n *\n * Uses prototype chain walking with constructor names rather than instanceof,\n * so it works in Node at build time without requiring the cloudflare:workers\n * module (which only exists in the Workers runtime).\n *\n * This is used to differentiate between different Cloudflare worker types:\n * - WorkerEntrypoint: Class-based workers (used with instrumentWorkerEntrypoint)\n * - DurableObject: Durable Object classes\n * - Workflow: Workflow classes\n *\n * For ExportedHandler (plain objects), this will return false for all types.\n *\n * @param value - The value to check (typically a class constructor)\n * @param className - The Cloudflare base class name to check against\n * @returns true if the value is a class that extends the specified Cloudflare class\n *\n * @example\n * ```ts\n * isCloudflareClass(MyWorker, 'WorkerEntrypoint') // true if MyWorker extends WorkerEntrypoint\n * isCloudflareClass(MyDO, 'DurableObject') // true if MyDO extends DurableObject\n * ```\n */\nexport function isCloudflareClass(\n value: unknown,\n className: 'WorkerEntrypoint',\n // oxlint-disable-next-line typescript/no-explicit-any\n): value is WorkerEntrypointConstructor<any, any>;\nexport function isCloudflareClass(\n value: unknown,\n className: 'DurableObject',\n): value is new (...args: unknown[]) => DurableObject;\nexport function isCloudflareClass(\n value: unknown,\n className: 'WorkflowEntrypoint',\n): value is new (...args: unknown[]) => WorkflowEntrypoint;\nexport function isCloudflareClass(value: unknown, className: CloudflareClassName): boolean {\n if (!value || typeof value !== 'function') {\n return false;\n }\n\n if (value.name === className) {\n return false;\n }\n\n let proto: object | null = value.prototype;\n\n while (proto) {\n const ctor = (proto as { constructor?: { name?: string } }).constructor;\n const constructorName = ctor?.name;\n\n if (constructorName === className) {\n return true;\n }\n\n proto = Object.getPrototypeOf(proto);\n }\n\n return false;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"isCloudflareClass.js","names":[],"sources":["../../../../src/utils/isCloudflareClass.ts"],"sourcesContent":["import type { DurableObject, WorkflowEntrypoint } from 'cloudflare:workers';\nimport type { WorkerEntrypointConstructor } from '../instrumentations/instrumentWorkerEntrypoint';\ntype CloudflareClassName = 'WorkerEntrypoint' | 'DurableObject' | 'WorkflowEntrypoint';\n\n/**\n * Checks if a class constructor extends a specific Cloudflare base class.\n *\n * Uses prototype chain walking with constructor names rather than instanceof,\n * so it works in Node at build time without requiring the cloudflare:workers\n * module (which only exists in the Workers runtime).\n *\n * This is used to differentiate between different Cloudflare worker types:\n * - WorkerEntrypoint: Class-based workers (used with instrumentWorkerEntrypoint)\n * - DurableObject: Durable Object classes\n * - Workflow: Workflow classes\n *\n * For ExportedHandler (plain objects), this will return false for all types.\n *\n * @param value - The value to check (typically a class constructor)\n * @param className - The Cloudflare base class name to check against\n * @returns true if the value is a class that extends the specified Cloudflare class\n *\n * @example\n * ```ts\n * isCloudflareClass(MyWorker, 'WorkerEntrypoint') // true if MyWorker extends WorkerEntrypoint\n * isCloudflareClass(MyDO, 'DurableObject') // true if MyDO extends DurableObject\n * ```\n */\nexport function isCloudflareClass(\n value: unknown,\n className: 'WorkerEntrypoint',\n // oxlint-disable-next-line typescript/no-explicit-any\n): value is WorkerEntrypointConstructor<any, any>;\nexport function isCloudflareClass(\n value: unknown,\n className: 'DurableObject',\n): value is new (...args: unknown[]) => DurableObject;\nexport function isCloudflareClass(\n value: unknown,\n className: 'WorkflowEntrypoint',\n): value is new (...args: unknown[]) => WorkflowEntrypoint;\nexport function isCloudflareClass(value: unknown, className: CloudflareClassName): boolean {\n if (!value || typeof value !== 'function') {\n return false;\n }\n\n if (value.name === className) {\n return false;\n }\n\n let proto: object | null = value.prototype;\n\n while (proto) {\n const ctor = (proto as { constructor?: { name?: string } }).constructor;\n const constructorName = ctor?.name;\n\n if (constructorName === className) {\n return true;\n }\n\n proto = Object.getPrototypeOf(proto);\n }\n\n return false;\n}\n"],"mappings":";AAyCA,SAAgB,kBAAkB,OAAgB,WAAyC;CACzF,IAAI,CAAC,SAAS,OAAO,UAAU,YAC7B,OAAO;CAGT,IAAI,MAAM,SAAS,WACjB,OAAO;CAGT,IAAI,QAAuB,MAAM;CAEjC,OAAO,OAAO;EAIZ,IAHc,MAA8C,aAC9B,SAEN,WACtB,OAAO;EAGT,QAAQ,OAAO,eAAe,KAAK;CACrC;CAEA,OAAO;AACT"}
|
|
@@ -1,44 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const core = require('@sentry/core');
|
|
4
|
-
|
|
1
|
+
let _sentry_core = require("@sentry/core");
|
|
2
|
+
// src/utils/queueTraceMeta.ts
|
|
5
3
|
const SENTRY_QUEUE_TRACE_KEY = "__sentry_queue_trace__";
|
|
6
4
|
function isQueueTraceCarrier(body) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const prototype = Object.getPrototypeOf(body);
|
|
11
|
-
return prototype === Object.prototype || prototype === null;
|
|
5
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return false;
|
|
6
|
+
const prototype = Object.getPrototypeOf(body);
|
|
7
|
+
return prototype === Object.prototype || prototype === null;
|
|
12
8
|
}
|
|
13
9
|
function addQueueTraceContext(body, sentryTrace) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
if (!isQueueTraceCarrier(body) || !sentryTrace || Object.prototype.hasOwnProperty.call(body, SENTRY_QUEUE_TRACE_KEY)) return body;
|
|
11
|
+
return {
|
|
12
|
+
...body,
|
|
13
|
+
[SENTRY_QUEUE_TRACE_KEY]: sentryTrace
|
|
14
|
+
};
|
|
18
15
|
}
|
|
19
16
|
function extractQueueTraceContext(body) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!traceparentData?.traceId || !traceparentData.parentSpanId) {
|
|
33
|
-
return void 0;
|
|
34
|
-
}
|
|
35
|
-
return {
|
|
36
|
-
traceId: traceparentData.traceId,
|
|
37
|
-
spanId: traceparentData.parentSpanId,
|
|
38
|
-
sampled: traceparentData.parentSampled
|
|
39
|
-
};
|
|
17
|
+
if (!isQueueTraceCarrier(body)) return;
|
|
18
|
+
if (!Object.prototype.hasOwnProperty.call(body, SENTRY_QUEUE_TRACE_KEY)) return;
|
|
19
|
+
const sentryTrace = body[SENTRY_QUEUE_TRACE_KEY];
|
|
20
|
+
Reflect.deleteProperty(body, SENTRY_QUEUE_TRACE_KEY);
|
|
21
|
+
if (typeof sentryTrace !== "string") return;
|
|
22
|
+
const traceparentData = (0, _sentry_core.extractTraceparentData)(sentryTrace);
|
|
23
|
+
if (!traceparentData?.traceId || !traceparentData.parentSpanId) return;
|
|
24
|
+
return {
|
|
25
|
+
traceId: traceparentData.traceId,
|
|
26
|
+
spanId: traceparentData.parentSpanId,
|
|
27
|
+
sampled: traceparentData.parentSampled
|
|
28
|
+
};
|
|
40
29
|
}
|
|
41
|
-
|
|
42
30
|
exports.addQueueTraceContext = addQueueTraceContext;
|
|
43
31
|
exports.extractQueueTraceContext = extractQueueTraceContext;
|
|
44
|
-
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=queueTraceMeta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queueTraceMeta.js","sources":["../../../../src/utils/queueTraceMeta.ts"],"sourcesContent":["import { extractTraceparentData } from '@sentry/core';\n\nconst SENTRY_QUEUE_TRACE_KEY = '__sentry_queue_trace__';\n\nfunction isQueueTraceCarrier(body: unknown): body is Record<string, unknown> {\n if (typeof body !== 'object' || body === null || Array.isArray(body)) {\n return false;\n }\n\n // Cloudflare Queues has no message-header API. Only record-like bodies can carry a named field; binary data and\n // other structured-clone values must pass through untouched.\n const prototype = Object.getPrototypeOf(body);\n return prototype === Object.prototype || prototype === null;\n}\n\nexport function addQueueTraceContext(body: unknown, sentryTrace: string | undefined): unknown {\n if (\n !isQueueTraceCarrier(body) ||\n !sentryTrace ||\n Object.prototype.hasOwnProperty.call(body, SENTRY_QUEUE_TRACE_KEY)\n ) {\n return body;\n }\n\n // Cloudflare rejects messages over 128 KB (https://developers.cloudflare.com/queues/platform/limits/),\n // and the field adds about 80 bytes, so a payload right under the limit can start failing to send.\n // Span links only need `sentry-trace`, so baggage would only cost more of that budget. Copy instead\n // of mutating, because callers may reuse a payload after enqueueing it.\n return { ...body, [SENTRY_QUEUE_TRACE_KEY]: sentryTrace };\n}\n\nexport function extractQueueTraceContext(\n body: unknown,\n): { traceId: string; spanId: string; sampled: boolean | undefined } | undefined {\n if (!isQueueTraceCarrier(body)) {\n return undefined;\n }\n\n if (!Object.prototype.hasOwnProperty.call(body, SENTRY_QUEUE_TRACE_KEY)) {\n return undefined;\n }\n\n const sentryTrace = body[SENTRY_QUEUE_TRACE_KEY];\n\n // The key is reserved transport metadata, so strip it even if its value is not a valid trace.\n // Unlike `delete`, this returns false instead of throwing on frozen bodies, which keep the field.\n Reflect.deleteProperty(body, SENTRY_QUEUE_TRACE_KEY);\n\n if (typeof sentryTrace !== 'string') {\n return undefined;\n }\n\n const traceparentData = extractTraceparentData(sentryTrace);\n if (!traceparentData?.traceId || !traceparentData.parentSpanId) {\n return undefined;\n }\n\n return {\n traceId: traceparentData.traceId,\n spanId: traceparentData.parentSpanId,\n sampled: traceparentData.parentSampled,\n };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"queueTraceMeta.js","names":["extractTraceparentData"],"sources":["../../../../src/utils/queueTraceMeta.ts"],"sourcesContent":["import { extractTraceparentData } from '@sentry/core';\n\nconst SENTRY_QUEUE_TRACE_KEY = '__sentry_queue_trace__';\n\nfunction isQueueTraceCarrier(body: unknown): body is Record<string, unknown> {\n if (typeof body !== 'object' || body === null || Array.isArray(body)) {\n return false;\n }\n\n // Cloudflare Queues has no message-header API. Only record-like bodies can carry a named field; binary data and\n // other structured-clone values must pass through untouched.\n const prototype = Object.getPrototypeOf(body);\n return prototype === Object.prototype || prototype === null;\n}\n\nexport function addQueueTraceContext(body: unknown, sentryTrace: string | undefined): unknown {\n if (\n !isQueueTraceCarrier(body) ||\n !sentryTrace ||\n Object.prototype.hasOwnProperty.call(body, SENTRY_QUEUE_TRACE_KEY)\n ) {\n return body;\n }\n\n // Cloudflare rejects messages over 128 KB (https://developers.cloudflare.com/queues/platform/limits/),\n // and the field adds about 80 bytes, so a payload right under the limit can start failing to send.\n // Span links only need `sentry-trace`, so baggage would only cost more of that budget. Copy instead\n // of mutating, because callers may reuse a payload after enqueueing it.\n return { ...body, [SENTRY_QUEUE_TRACE_KEY]: sentryTrace };\n}\n\nexport function extractQueueTraceContext(\n body: unknown,\n): { traceId: string; spanId: string; sampled: boolean | undefined } | undefined {\n if (!isQueueTraceCarrier(body)) {\n return undefined;\n }\n\n if (!Object.prototype.hasOwnProperty.call(body, SENTRY_QUEUE_TRACE_KEY)) {\n return undefined;\n }\n\n const sentryTrace = body[SENTRY_QUEUE_TRACE_KEY];\n\n // The key is reserved transport metadata, so strip it even if its value is not a valid trace.\n // Unlike `delete`, this returns false instead of throwing on frozen bodies, which keep the field.\n Reflect.deleteProperty(body, SENTRY_QUEUE_TRACE_KEY);\n\n if (typeof sentryTrace !== 'string') {\n return undefined;\n }\n\n const traceparentData = extractTraceparentData(sentryTrace);\n if (!traceparentData?.traceId || !traceparentData.parentSpanId) {\n return undefined;\n }\n\n return {\n traceId: traceparentData.traceId,\n spanId: traceparentData.parentSpanId,\n sampled: traceparentData.parentSampled,\n };\n}\n"],"mappings":";;AAEA,MAAM,yBAAyB;AAE/B,SAAS,oBAAoB,MAAgD;CAC3E,IAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,IAAI,GACjE,OAAO;CAKT,MAAM,YAAY,OAAO,eAAe,IAAI;CAC5C,OAAO,cAAc,OAAO,aAAa,cAAc;AACzD;AAEA,SAAgB,qBAAqB,MAAe,aAA0C;CAC5F,IACE,CAAC,oBAAoB,IAAI,KACzB,CAAC,eACD,OAAO,UAAU,eAAe,KAAK,MAAM,sBAAsB,GAEjE,OAAO;CAOT,OAAO;EAAE,GAAG;GAAO,yBAAyB;CAAY;AAC1D;AAEA,SAAgB,yBACd,MAC+E;CAC/E,IAAI,CAAC,oBAAoB,IAAI,GAC3B;CAGF,IAAI,CAAC,OAAO,UAAU,eAAe,KAAK,MAAM,sBAAsB,GACpE;CAGF,MAAM,cAAc,KAAK;CAIzB,QAAQ,eAAe,MAAM,sBAAsB;CAEnD,IAAI,OAAO,gBAAgB,UACzB;CAGF,MAAM,mBAAA,GAAkBA,aAAAA,uBAAAA,CAAuB,WAAW;CAC1D,IAAI,CAAC,iBAAiB,WAAW,CAAC,gBAAgB,cAChD;CAGF,OAAO;EACL,SAAS,gBAAgB;EACzB,QAAQ,gBAAgB;EACxB,SAAS,gBAAgB;CAC3B;AACF"}
|
|
@@ -1,39 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
let _sentry_core = require("@sentry/core");
|
|
2
|
+
// src/utils/rpcMeta.ts
|
|
3
|
+
/**
|
|
4
|
+
* Key used to identify Sentry RPC metadata in a trailing argument.
|
|
5
|
+
* This enables transparent trace propagation across Cloudflare Workers RPC
|
|
6
|
+
* calls (Cap'n Proto), which have no native header/metadata support.
|
|
7
|
+
*/
|
|
5
8
|
const SENTRY_RPC_META_KEY = "__sentry_rpc_meta__";
|
|
6
9
|
function isSentryRpcMeta(value) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return core.isObjectLike(value[SENTRY_RPC_META_KEY]);
|
|
10
|
+
if (!(0, _sentry_core.isObjectLike)(value) || !(SENTRY_RPC_META_KEY in value)) return false;
|
|
11
|
+
return (0, _sentry_core.isObjectLike)(value[SENTRY_RPC_META_KEY]);
|
|
11
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Appends Sentry RPC metadata to an args array for trace propagation.
|
|
15
|
+
* If no active trace exists, returns the original args unchanged.
|
|
16
|
+
*/
|
|
12
17
|
function appendRpcMeta(args) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return [...args, { [SENTRY_RPC_META_KEY]: traceData }];
|
|
18
|
+
const traceData = (0, _sentry_core.getTraceData)();
|
|
19
|
+
if (!traceData["sentry-trace"]) return args;
|
|
20
|
+
return [...args, { [SENTRY_RPC_META_KEY]: traceData }];
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the trailing argument carries Sentry RPC metadata.
|
|
24
|
+
*
|
|
25
|
+
* Separate from {@link extractRpcMeta} because the RPC method wrappers run this check on every
|
|
26
|
+
* call — including the instance's own internal method calls, which never carry metadata — and
|
|
27
|
+
* must not allocate on that path.
|
|
28
|
+
*/
|
|
19
29
|
function hasRpcMeta(args) {
|
|
20
|
-
|
|
30
|
+
return args.length > 0 && isSentryRpcMeta(args[args.length - 1]);
|
|
21
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Extracts Sentry RPC metadata from the trailing argument of an args array.
|
|
34
|
+
* Returns cleaned args (without meta) and the extracted trace data if found.
|
|
35
|
+
*/
|
|
22
36
|
function extractRpcMeta(args) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
rpcMeta: last.__sentry_rpc_meta__
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return { args };
|
|
37
|
+
if (args.length === 0) return { args };
|
|
38
|
+
const last = args[args.length - 1];
|
|
39
|
+
if (isSentryRpcMeta(last)) return {
|
|
40
|
+
args: args.slice(0, -1),
|
|
41
|
+
rpcMeta: last.__sentry_rpc_meta__
|
|
42
|
+
};
|
|
43
|
+
return { args };
|
|
34
44
|
}
|
|
35
|
-
|
|
36
45
|
exports.appendRpcMeta = appendRpcMeta;
|
|
37
46
|
exports.extractRpcMeta = extractRpcMeta;
|
|
38
47
|
exports.hasRpcMeta = hasRpcMeta;
|
|
39
|
-
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=rpcMeta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpcMeta.js","sources":["../../../../src/utils/rpcMeta.ts"],"sourcesContent":["import { getTraceData, isObjectLike, type SerializedTraceData } from '@sentry/core';\n\n/**\n * Key used to identify Sentry RPC metadata in a trailing argument.\n * This enables transparent trace propagation across Cloudflare Workers RPC\n * calls (Cap'n Proto), which have no native header/metadata support.\n */\nconst SENTRY_RPC_META_KEY = '__sentry_rpc_meta__';\n\ninterface SentryRpcMeta {\n __sentry_rpc_meta__: SerializedTraceData;\n}\n\nfunction isSentryRpcMeta(value: unknown): value is SentryRpcMeta {\n if (!isObjectLike(value) || !(SENTRY_RPC_META_KEY in value)) {\n return false;\n }\n return isObjectLike(value[SENTRY_RPC_META_KEY]);\n}\n\n/**\n * Appends Sentry RPC metadata to an args array for trace propagation.\n * If no active trace exists, returns the original args unchanged.\n */\nexport function appendRpcMeta(args: unknown[]): unknown[] {\n const traceData = getTraceData();\n\n if (!traceData['sentry-trace']) {\n return args;\n }\n\n return [...args, { [SENTRY_RPC_META_KEY]: traceData }];\n}\n\n/**\n * Whether the trailing argument carries Sentry RPC metadata.\n *\n * Separate from {@link extractRpcMeta} because the RPC method wrappers run this check on every\n * call — including the instance's own internal method calls, which never carry metadata — and\n * must not allocate on that path.\n */\nexport function hasRpcMeta(args: unknown[]): boolean {\n return args.length > 0 && isSentryRpcMeta(args[args.length - 1]);\n}\n\n/**\n * Extracts Sentry RPC metadata from the trailing argument of an args array.\n * Returns cleaned args (without meta) and the extracted trace data if found.\n */\nexport function extractRpcMeta<T extends unknown[]>(\n args: T,\n): {\n args: T;\n rpcMeta?: SerializedTraceData;\n} {\n if (args.length === 0) {\n return { args };\n }\n\n const last = args[args.length - 1];\n if (isSentryRpcMeta(last)) {\n return {\n args: args.slice(0, -1) as T,\n rpcMeta: last.__sentry_rpc_meta__,\n };\n }\n\n return { args };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"rpcMeta.js","names":["isObjectLike","getTraceData"],"sources":["../../../../src/utils/rpcMeta.ts"],"sourcesContent":["import { getTraceData, isObjectLike, type SerializedTraceData } from '@sentry/core';\n\n/**\n * Key used to identify Sentry RPC metadata in a trailing argument.\n * This enables transparent trace propagation across Cloudflare Workers RPC\n * calls (Cap'n Proto), which have no native header/metadata support.\n */\nconst SENTRY_RPC_META_KEY = '__sentry_rpc_meta__';\n\ninterface SentryRpcMeta {\n __sentry_rpc_meta__: SerializedTraceData;\n}\n\nfunction isSentryRpcMeta(value: unknown): value is SentryRpcMeta {\n if (!isObjectLike(value) || !(SENTRY_RPC_META_KEY in value)) {\n return false;\n }\n return isObjectLike(value[SENTRY_RPC_META_KEY]);\n}\n\n/**\n * Appends Sentry RPC metadata to an args array for trace propagation.\n * If no active trace exists, returns the original args unchanged.\n */\nexport function appendRpcMeta(args: unknown[]): unknown[] {\n const traceData = getTraceData();\n\n if (!traceData['sentry-trace']) {\n return args;\n }\n\n return [...args, { [SENTRY_RPC_META_KEY]: traceData }];\n}\n\n/**\n * Whether the trailing argument carries Sentry RPC metadata.\n *\n * Separate from {@link extractRpcMeta} because the RPC method wrappers run this check on every\n * call — including the instance's own internal method calls, which never carry metadata — and\n * must not allocate on that path.\n */\nexport function hasRpcMeta(args: unknown[]): boolean {\n return args.length > 0 && isSentryRpcMeta(args[args.length - 1]);\n}\n\n/**\n * Extracts Sentry RPC metadata from the trailing argument of an args array.\n * Returns cleaned args (without meta) and the extracted trace data if found.\n */\nexport function extractRpcMeta<T extends unknown[]>(\n args: T,\n): {\n args: T;\n rpcMeta?: SerializedTraceData;\n} {\n if (args.length === 0) {\n return { args };\n }\n\n const last = args[args.length - 1];\n if (isSentryRpcMeta(last)) {\n return {\n args: args.slice(0, -1) as T,\n rpcMeta: last.__sentry_rpc_meta__,\n };\n }\n\n return { args };\n}\n"],"mappings":";;;;;;;AAOA,MAAM,sBAAsB;AAM5B,SAAS,gBAAgB,OAAwC;CAC/D,IAAI,EAAA,GAACA,aAAAA,aAAAA,CAAa,KAAK,KAAK,EAAE,uBAAuB,QACnD,OAAO;CAET,QAAA,GAAOA,aAAAA,aAAAA,CAAa,MAAM,oBAAoB;AAChD;;;;;AAMA,SAAgB,cAAc,MAA4B;CACxD,MAAM,aAAA,GAAYC,aAAAA,aAAAA,CAAa;CAE/B,IAAI,CAAC,UAAU,iBACb,OAAO;CAGT,OAAO,CAAC,GAAG,MAAM,GAAG,sBAAsB,UAAU,CAAC;AACvD;;;;;;;;AASA,SAAgB,WAAW,MAA0B;CACnD,OAAO,KAAK,SAAS,KAAK,gBAAgB,KAAK,KAAK,SAAS,EAAE;AACjE;;;;;AAMA,SAAgB,eACd,MAIA;CACA,IAAI,KAAK,WAAW,GAClB,OAAO,EAAE,KAAK;CAGhB,MAAM,OAAO,KAAK,KAAK,SAAS;CAChC,IAAI,gBAAgB,IAAI,GACtB,OAAO;EACL,MAAM,KAAK,MAAM,GAAG,EAAE;EACtB,SAAS,KAAK;CAChB;CAGF,OAAO,EAAE,KAAK;AAChB"}
|
|
@@ -1,55 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const require_debug_build = require("../debug-build.js");
|
|
2
|
+
let _sentry_core = require("@sentry/core");
|
|
3
|
+
let _sentry_conventions_attributes = require("@sentry/conventions/attributes");
|
|
4
|
+
let _opentelemetry_api = require("@opentelemetry/api");
|
|
5
|
+
// src/utils/traceLinks.ts
|
|
6
|
+
/** Storage key prefix for the span context that links consecutive method invocations */
|
|
8
7
|
const SENTRY_TRACE_LINK_KEY_PREFIX = "__SENTRY_TRACE_LINK__";
|
|
8
|
+
/**
|
|
9
|
+
* Gets the storage key for a specific method's trace link.
|
|
10
|
+
*/
|
|
9
11
|
function getTraceLinkKey(methodName) {
|
|
10
|
-
|
|
12
|
+
return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`;
|
|
11
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Stores the current span context in Durable Object storage for trace linking.
|
|
16
|
+
* Uses the original uninstrumented storage to avoid creating spans for internal operations.
|
|
17
|
+
* Errors are silently ignored to prevent internal storage failures from propagating to user code.
|
|
18
|
+
*/
|
|
12
19
|
function storeSpanContext(originalStorage, methodName) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
try {
|
|
21
|
+
const activeSpan = (0, _sentry_core.getActiveSpan)();
|
|
22
|
+
if (activeSpan) {
|
|
23
|
+
const spanContext = activeSpan.spanContext();
|
|
24
|
+
const storedContext = {
|
|
25
|
+
traceId: spanContext.traceId,
|
|
26
|
+
spanId: spanContext.spanId,
|
|
27
|
+
sampled: (0, _sentry_core.spanIsSampled)(activeSpan)
|
|
28
|
+
};
|
|
29
|
+
originalStorage.kv.put(getTraceLinkKey(methodName), storedContext);
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
require_debug_build.DEBUG_BUILD && _sentry_core.debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);
|
|
33
|
+
}
|
|
27
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves a stored span context from Durable Object storage.
|
|
37
|
+
* Errors are silently ignored to prevent internal storage failures from propagating to user code.
|
|
38
|
+
*/
|
|
28
39
|
function getStoredSpanContext(originalStorage, methodName) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
try {
|
|
41
|
+
return originalStorage.kv.get(getTraceLinkKey(methodName));
|
|
42
|
+
} catch (error) {
|
|
43
|
+
require_debug_build.DEBUG_BUILD && _sentry_core.debug.log(`[CloudflareClient] Error retrieving span context for method ${methodName}`, error);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
35
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Builds span links from a stored span context.
|
|
49
|
+
*/
|
|
36
50
|
function buildSpanLinks(storedContext) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
[attributes.SENTRY_LINK_TYPE]: "previous_trace"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
];
|
|
51
|
+
return [{
|
|
52
|
+
context: {
|
|
53
|
+
traceId: storedContext.traceId,
|
|
54
|
+
spanId: storedContext.spanId,
|
|
55
|
+
traceFlags: storedContext.sampled ? _opentelemetry_api.TraceFlags.SAMPLED : _opentelemetry_api.TraceFlags.NONE
|
|
56
|
+
},
|
|
57
|
+
attributes: { [_sentry_conventions_attributes.SENTRY_LINK_TYPE]: "previous_trace" }
|
|
58
|
+
}];
|
|
49
59
|
}
|
|
50
|
-
|
|
51
60
|
exports.buildSpanLinks = buildSpanLinks;
|
|
52
61
|
exports.getStoredSpanContext = getStoredSpanContext;
|
|
53
62
|
exports.getTraceLinkKey = getTraceLinkKey;
|
|
54
63
|
exports.storeSpanContext = storeSpanContext;
|
|
55
|
-
|
|
64
|
+
|
|
65
|
+
//# sourceMappingURL=traceLinks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traceLinks.js","sources":["../../../../src/utils/traceLinks.ts"],"sourcesContent":["import { SENTRY_LINK_TYPE } from '@sentry/conventions/attributes';\nimport type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport { TraceFlags } from '@opentelemetry/api';\nimport type { SpanLink } from '@sentry/core';\nimport { debug, getActiveSpan, spanIsSampled } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/** Storage key prefix for the span context that links consecutive method invocations */\nconst SENTRY_TRACE_LINK_KEY_PREFIX = '__SENTRY_TRACE_LINK__';\n\n/** Stored span context for creating span links */\nexport interface StoredSpanContext {\n traceId: string;\n spanId: string;\n sampled: boolean;\n}\n\n/**\n * Gets the storage key for a specific method's trace link.\n */\nexport function getTraceLinkKey(methodName: string): string {\n return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`;\n}\n\n/**\n * Stores the current span context in Durable Object storage for trace linking.\n * Uses the original uninstrumented storage to avoid creating spans for internal operations.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport function storeSpanContext(originalStorage: DurableObjectStorage, methodName: string): void {\n try {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const spanContext = activeSpan.spanContext();\n const storedContext: StoredSpanContext = {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n sampled: spanIsSampled(activeSpan),\n };\n\n originalStorage.kv.put(getTraceLinkKey(methodName), storedContext);\n }\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);\n }\n}\n\n/**\n * Retrieves a stored span context from Durable Object storage.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport function getStoredSpanContext(\n originalStorage: DurableObjectStorage,\n methodName: string,\n): StoredSpanContext | undefined {\n try {\n return originalStorage.kv.get<StoredSpanContext>(getTraceLinkKey(methodName));\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error retrieving span context for method ${methodName}`, error);\n return undefined;\n }\n}\n\n/**\n * Builds span links from a stored span context.\n */\nexport function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[] {\n return [\n {\n context: {\n traceId: storedContext.traceId,\n spanId: storedContext.spanId,\n traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n },\n attributes: {\n [SENTRY_LINK_TYPE]: 'previous_trace',\n },\n },\n ];\n}\n"],"
|
|
1
|
+
{"version":3,"file":"traceLinks.js","names":["getActiveSpan","spanIsSampled","DEBUG_BUILD","debug","TraceFlags","SENTRY_LINK_TYPE"],"sources":["../../../../src/utils/traceLinks.ts"],"sourcesContent":["import { SENTRY_LINK_TYPE } from '@sentry/conventions/attributes';\nimport type { DurableObjectStorage } from '@cloudflare/workers-types';\nimport { TraceFlags } from '@opentelemetry/api';\nimport type { SpanLink } from '@sentry/core';\nimport { debug, getActiveSpan, spanIsSampled } from '@sentry/core';\nimport { DEBUG_BUILD } from '../debug-build';\n\n/** Storage key prefix for the span context that links consecutive method invocations */\nconst SENTRY_TRACE_LINK_KEY_PREFIX = '__SENTRY_TRACE_LINK__';\n\n/** Stored span context for creating span links */\nexport interface StoredSpanContext {\n traceId: string;\n spanId: string;\n sampled: boolean;\n}\n\n/**\n * Gets the storage key for a specific method's trace link.\n */\nexport function getTraceLinkKey(methodName: string): string {\n return `${SENTRY_TRACE_LINK_KEY_PREFIX}${methodName}`;\n}\n\n/**\n * Stores the current span context in Durable Object storage for trace linking.\n * Uses the original uninstrumented storage to avoid creating spans for internal operations.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport function storeSpanContext(originalStorage: DurableObjectStorage, methodName: string): void {\n try {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const spanContext = activeSpan.spanContext();\n const storedContext: StoredSpanContext = {\n traceId: spanContext.traceId,\n spanId: spanContext.spanId,\n sampled: spanIsSampled(activeSpan),\n };\n\n originalStorage.kv.put(getTraceLinkKey(methodName), storedContext);\n }\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error storing span context for method ${methodName}`, error);\n }\n}\n\n/**\n * Retrieves a stored span context from Durable Object storage.\n * Errors are silently ignored to prevent internal storage failures from propagating to user code.\n */\nexport function getStoredSpanContext(\n originalStorage: DurableObjectStorage,\n methodName: string,\n): StoredSpanContext | undefined {\n try {\n return originalStorage.kv.get<StoredSpanContext>(getTraceLinkKey(methodName));\n } catch (error) {\n // Silently ignore storage errors to prevent internal failures from affecting user code\n DEBUG_BUILD && debug.log(`[CloudflareClient] Error retrieving span context for method ${methodName}`, error);\n return undefined;\n }\n}\n\n/**\n * Builds span links from a stored span context.\n */\nexport function buildSpanLinks(storedContext: StoredSpanContext): SpanLink[] {\n return [\n {\n context: {\n traceId: storedContext.traceId,\n spanId: storedContext.spanId,\n traceFlags: storedContext.sampled ? TraceFlags.SAMPLED : TraceFlags.NONE,\n },\n attributes: {\n [SENTRY_LINK_TYPE]: 'previous_trace',\n },\n },\n ];\n}\n"],"mappings":";;;;;;AAQA,MAAM,+BAA+B;;;;AAYrC,SAAgB,gBAAgB,YAA4B;CAC1D,OAAO,GAAG,+BAA+B;AAC3C;;;;;;AAOA,SAAgB,iBAAiB,iBAAuC,YAA0B;CAChG,IAAI;EACF,MAAM,cAAA,GAAaA,aAAAA,cAAAA,CAAc;EACjC,IAAI,YAAY;GACd,MAAM,cAAc,WAAW,YAAY;GAC3C,MAAM,gBAAmC;IACvC,SAAS,YAAY;IACrB,QAAQ,YAAY;IACpB,UAAA,GAASC,aAAAA,cAAAA,CAAc,UAAU;GACnC;GAEA,gBAAgB,GAAG,IAAI,gBAAgB,UAAU,GAAG,aAAa;EACnE;CACF,SAAS,OAAO;EAEdC,oBAAAA,eAAeC,aAAAA,MAAM,IAAI,4DAA4D,cAAc,KAAK;CAC1G;AACF;;;;;AAMA,SAAgB,qBACd,iBACA,YAC+B;CAC/B,IAAI;EACF,OAAO,gBAAgB,GAAG,IAAuB,gBAAgB,UAAU,CAAC;CAC9E,SAAS,OAAO;EAEdD,oBAAAA,eAAeC,aAAAA,MAAM,IAAI,+DAA+D,cAAc,KAAK;EAC3G;CACF;AACF;;;;AAKA,SAAgB,eAAe,eAA8C;CAC3E,OAAO,CACL;EACE,SAAS;GACP,SAAS,cAAc;GACvB,QAAQ,cAAc;GACtB,YAAY,cAAc,UAAUC,mBAAAA,WAAW,UAAUA,mBAAAA,WAAW;EACtE;EACA,YAAY,GACTC,+BAAAA,mBAAmB,iBACtB;CACF,CACF;AACF"}
|