@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrion-diagnostics-channel.js","sources":["../../../src/orchestrion-diagnostics-channel.ts"],"sourcesContent":["/**\n * A workerd-safe `diagnostics_channel` façade for the orchestrion EMIT side, and the\n * `dcModule` target for the Cloudflare orchestrion build (see `vite/index.ts`): orchestrion's\n * transformed code imports `tracingChannel` from here (its default export) instead of\n * `node:diagnostics_channel`.\n *\n * On workerd, `channel.publish()` and `channel.runStores()` throw at module/global scope\n * (\"Disallowed operation called within global scope …\"); only inside a request handler do they\n * work. `subscribe` and channel creation are fine anywhere. Orchestrion's transformed code emits\n * `start.runStores(...)` / `end.publish(...)` at each wrapped call site, so a library\n * instantiated at module scope (`const app = new Hono()`) throws the moment it is wrapped — or,\n * if no subscriber exists yet, is skipped by the wrapper's `if (!hasSubscribers) return\n * __apm$traced()` short-circuit and never instrumented.\n *\n * This façade delegates to the real `node:diagnostics_channel` singletons — so subscribers, which\n * keep subscribing through `node:diagnostics_channel`, are reached unchanged — and changes two\n * things:\n *\n * 1. `hasSubscribers` always reports `true`, so the wrapper never short-circuits. On Cloudflare a\n * channel is only injected for an integration that is actually bundled, so the short-circuit\n * buys nothing — and disabling it is what lets the wrapper run (and reach us) at module scope,\n * before the per-request cached `init()` has subscribed.\n * 2. When a delegated `publish`/`runStores` throws the global-scope error, the event is queued via\n * {@link deferChannelEvent} instead. {@link flushDeferredChannelEvents}, called at the top of\n * the request handler after `init()`, emits it via the real channel — now inside a request,\n * where publish works.\n *\n * In a request handler nothing throws, so every call is a transparent pass-through to the real\n * channel: lifecycle channels (spans, context binding) behave exactly as on Node.\n */\nimport * as realDc from 'node:diagnostics_channel';\nimport { deferChannelEvent, isGlobalScopeError } from './orchestrion-deferred-channels';\n\ntype Ctx = Record<string, unknown>;\n\n// One façade per channel name (node's `tracingChannel` is itself a per-name singleton), built\n// once when the transformed module declares `const CH = tracingChannel(name)`.\nconst cache = new Map<string, realDc.TracingChannel>();\n\n// `Channel.hasSubscribers` is a getter on Node but a method on workerd — normalize both to a\n// boolean. (This shape difference is also why the emit wrapper never short-circuits on workerd:\n// its `if (!ch.start.hasSubscribers)` guard reads a truthy method reference.)\nfunction channelHasSubscribers(ch: realDc.Channel): boolean {\n const value = (ch as { hasSubscribers: unknown }).hasSubscribers;\n return typeof value === 'function' ? Boolean((value as () => unknown).call(ch)) : Boolean(value);\n}\n\nfunction wrapSubChannel(tracing: realDc.TracingChannel, real: realDc.Channel): realDc.Channel {\n return {\n name: real.name,\n // A method (not a getter) so it reads truthy as a property in the emit guard *and* is callable,\n // matching workerd's native shape. Forced `true`: on Cloudflare a channel is only injected for a\n // bundled integration, so the wrapper's no-subscriber short-circuit buys nothing — and disabling\n // it is what lets the wrapper run (and reach us) at module scope before `init()` has subscribed.\n hasSubscribers(): boolean {\n return true;\n },\n publish(ctx: Ctx): void {\n // Snapshot subscriber presence before publishing — it decides whether to defer if the\n // global-scope error fires below.\n const hadSubscribers = channelHasSubscribers(real);\n try {\n real.publish(ctx);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // We're at module scope (workerd throws here even with no subscribers). If someone was\n // already subscribed — top-level `Sentry.init()` — workerd delivered to them before\n // throwing, so they got it exactly once; don't defer. Otherwise — the common per-request\n // cached-init case — nobody received it, so defer for a subscriber that registers later\n // (at `init()`), which then gets it exactly once. In a request `publish` doesn't throw,\n // so this path never defers a normal in-request event.\n if (!hadSubscribers) {\n deferChannelEvent(tracing, ctx);\n }\n }\n },\n runStores(ctx: Ctx, fn: (...args: unknown[]) => unknown, ...rest: unknown[]): unknown {\n try {\n return real.runStores(ctx, fn, ...rest);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // publish() is gated too, so the store can't be established — just run the wrapped call\n // so its return value (e.g. the constructed instance) is produced now. Its own\n // `end.publish` runs back through this façade and is deferred.\n return fn();\n }\n },\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n bindStore: real.bindStore.bind(real),\n unbindStore: real.unbindStore.bind(real),\n } as unknown as realDc.Channel;\n}\n\nexport function tracingChannel<T = Ctx>(name: string): realDc.TracingChannel<T> {\n const cached = cache.get(name);\n if (cached) {\n return cached;\n }\n\n const real = realDc.tracingChannel(name);\n const facade = {\n start: wrapSubChannel(real, real.start),\n end: wrapSubChannel(real, real.end),\n asyncStart: wrapSubChannel(real, real.asyncStart),\n asyncEnd: wrapSubChannel(real, real.asyncEnd),\n error: wrapSubChannel(real, real.error),\n // Iterator (`:next`) channels call these on the tracingChannel itself; delegate to the real\n // implementation (they only run in-request, where publish/runStores are allowed).\n traceSync: real.traceSync.bind(real),\n tracePromise: real.tracePromise.bind(real),\n traceCallback: real.traceCallback.bind(real),\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n } as unknown as realDc.TracingChannel<T>;\n\n cache.set(name, facade);\n return facade;\n}\n\nexport const channel = realDc.channel;\nexport const subscribe = realDc.subscribe;\nexport const unsubscribe = realDc.unsubscribe;\n\n// Orchestrion's emit imports the default and destructures `tracingChannel`.\nexport default { tracingChannel, channel, subscribe, unsubscribe };\n"],"
|
|
1
|
+
{"version":3,"file":"orchestrion-diagnostics-channel.js","names":[],"sources":["../../../src/orchestrion-diagnostics-channel.ts"],"sourcesContent":["/**\n * A workerd-safe `diagnostics_channel` façade for the orchestrion EMIT side, and the\n * `dcModule` target for the Cloudflare orchestrion build (see `vite/index.ts`): orchestrion's\n * transformed code imports `tracingChannel` from here (its default export) instead of\n * `node:diagnostics_channel`.\n *\n * On workerd, `channel.publish()` and `channel.runStores()` throw at module/global scope\n * (\"Disallowed operation called within global scope …\"); only inside a request handler do they\n * work. `subscribe` and channel creation are fine anywhere. Orchestrion's transformed code emits\n * `start.runStores(...)` / `end.publish(...)` at each wrapped call site, so a library\n * instantiated at module scope (`const app = new Hono()`) throws the moment it is wrapped — or,\n * if no subscriber exists yet, is skipped by the wrapper's `if (!hasSubscribers) return\n * __apm$traced()` short-circuit and never instrumented.\n *\n * This façade delegates to the real `node:diagnostics_channel` singletons — so subscribers, which\n * keep subscribing through `node:diagnostics_channel`, are reached unchanged — and changes two\n * things:\n *\n * 1. `hasSubscribers` always reports `true`, so the wrapper never short-circuits. On Cloudflare a\n * channel is only injected for an integration that is actually bundled, so the short-circuit\n * buys nothing — and disabling it is what lets the wrapper run (and reach us) at module scope,\n * before the per-request cached `init()` has subscribed.\n * 2. When a delegated `publish`/`runStores` throws the global-scope error, the event is queued via\n * {@link deferChannelEvent} instead. {@link flushDeferredChannelEvents}, called at the top of\n * the request handler after `init()`, emits it via the real channel — now inside a request,\n * where publish works.\n *\n * In a request handler nothing throws, so every call is a transparent pass-through to the real\n * channel: lifecycle channels (spans, context binding) behave exactly as on Node.\n */\nimport * as realDc from 'node:diagnostics_channel';\nimport { deferChannelEvent, isGlobalScopeError } from './orchestrion-deferred-channels';\n\ntype Ctx = Record<string, unknown>;\n\n// One façade per channel name (node's `tracingChannel` is itself a per-name singleton), built\n// once when the transformed module declares `const CH = tracingChannel(name)`.\nconst cache = new Map<string, realDc.TracingChannel>();\n\n// `Channel.hasSubscribers` is a getter on Node but a method on workerd — normalize both to a\n// boolean. (This shape difference is also why the emit wrapper never short-circuits on workerd:\n// its `if (!ch.start.hasSubscribers)` guard reads a truthy method reference.)\nfunction channelHasSubscribers(ch: realDc.Channel): boolean {\n const value = (ch as { hasSubscribers: unknown }).hasSubscribers;\n return typeof value === 'function' ? Boolean((value as () => unknown).call(ch)) : Boolean(value);\n}\n\nfunction wrapSubChannel(tracing: realDc.TracingChannel, real: realDc.Channel): realDc.Channel {\n return {\n name: real.name,\n // A method (not a getter) so it reads truthy as a property in the emit guard *and* is callable,\n // matching workerd's native shape. Forced `true`: on Cloudflare a channel is only injected for a\n // bundled integration, so the wrapper's no-subscriber short-circuit buys nothing — and disabling\n // it is what lets the wrapper run (and reach us) at module scope before `init()` has subscribed.\n hasSubscribers(): boolean {\n return true;\n },\n publish(ctx: Ctx): void {\n // Snapshot subscriber presence before publishing — it decides whether to defer if the\n // global-scope error fires below.\n const hadSubscribers = channelHasSubscribers(real);\n try {\n real.publish(ctx);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // We're at module scope (workerd throws here even with no subscribers). If someone was\n // already subscribed — top-level `Sentry.init()` — workerd delivered to them before\n // throwing, so they got it exactly once; don't defer. Otherwise — the common per-request\n // cached-init case — nobody received it, so defer for a subscriber that registers later\n // (at `init()`), which then gets it exactly once. In a request `publish` doesn't throw,\n // so this path never defers a normal in-request event.\n if (!hadSubscribers) {\n deferChannelEvent(tracing, ctx);\n }\n }\n },\n runStores(ctx: Ctx, fn: (...args: unknown[]) => unknown, ...rest: unknown[]): unknown {\n try {\n return real.runStores(ctx, fn, ...rest);\n } catch (error) {\n if (!isGlobalScopeError(error)) {\n throw error;\n }\n // publish() is gated too, so the store can't be established — just run the wrapped call\n // so its return value (e.g. the constructed instance) is produced now. Its own\n // `end.publish` runs back through this façade and is deferred.\n return fn();\n }\n },\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n bindStore: real.bindStore.bind(real),\n unbindStore: real.unbindStore.bind(real),\n } as unknown as realDc.Channel;\n}\n\nexport function tracingChannel<T = Ctx>(name: string): realDc.TracingChannel<T> {\n const cached = cache.get(name);\n if (cached) {\n return cached;\n }\n\n const real = realDc.tracingChannel(name);\n const facade = {\n start: wrapSubChannel(real, real.start),\n end: wrapSubChannel(real, real.end),\n asyncStart: wrapSubChannel(real, real.asyncStart),\n asyncEnd: wrapSubChannel(real, real.asyncEnd),\n error: wrapSubChannel(real, real.error),\n // Iterator (`:next`) channels call these on the tracingChannel itself; delegate to the real\n // implementation (they only run in-request, where publish/runStores are allowed).\n traceSync: real.traceSync.bind(real),\n tracePromise: real.tracePromise.bind(real),\n traceCallback: real.traceCallback.bind(real),\n subscribe: real.subscribe.bind(real),\n unsubscribe: real.unsubscribe.bind(real),\n } as unknown as realDc.TracingChannel<T>;\n\n cache.set(name, facade);\n return facade;\n}\n\nexport const channel = realDc.channel;\nexport const subscribe = realDc.subscribe;\nexport const unsubscribe = realDc.unsubscribe;\n\n// Orchestrion's emit imports the default and destructures `tracingChannel`.\nexport default { tracingChannel, channel, subscribe, unsubscribe };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,wBAAQ,IAAI,IAAmC;AAKrD,SAAS,sBAAsB,IAA6B;CAC1D,MAAM,QAAS,GAAmC;CAClD,OAAO,OAAO,UAAU,aAAa,QAAS,MAAwB,KAAK,EAAE,CAAC,IAAI,QAAQ,KAAK;AACjG;AAEA,SAAS,eAAe,SAAgC,MAAsC;CAC5F,OAAO;EACL,MAAM,KAAK;EAKX,iBAA0B;GACxB,OAAO;EACT;EACA,QAAQ,KAAgB;GAGtB,MAAM,iBAAiB,sBAAsB,IAAI;GACjD,IAAI;IACF,KAAK,QAAQ,GAAG;GAClB,SAAS,OAAO;IACd,IAAI,CAAC,mBAAmB,KAAK,GAC3B,MAAM;IAQR,IAAI,CAAC,gBACH,kBAAkB,SAAS,GAAG;GAElC;EACF;EACA,UAAU,KAAU,IAAqC,GAAG,MAA0B;GACpF,IAAI;IACF,OAAO,KAAK,UAAU,KAAK,IAAI,GAAG,IAAI;GACxC,SAAS,OAAO;IACd,IAAI,CAAC,mBAAmB,KAAK,GAC3B,MAAM;IAKR,OAAO,GAAG;GACZ;EACF;EACA,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,aAAa,KAAK,YAAY,KAAK,IAAI;EACvC,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,aAAa,KAAK,YAAY,KAAK,IAAI;CACzC;AACF;AAEA,SAAgB,eAAwB,MAAwC;CAC9E,MAAM,SAAS,MAAM,IAAI,IAAI;CAC7B,IAAI,QACF,OAAO;CAGT,MAAM,OAAO,OAAO,eAAe,IAAI;CACvC,MAAM,SAAS;EACb,OAAO,eAAe,MAAM,KAAK,KAAK;EACtC,KAAK,eAAe,MAAM,KAAK,GAAG;EAClC,YAAY,eAAe,MAAM,KAAK,UAAU;EAChD,UAAU,eAAe,MAAM,KAAK,QAAQ;EAC5C,OAAO,eAAe,MAAM,KAAK,KAAK;EAGtC,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,cAAc,KAAK,aAAa,KAAK,IAAI;EACzC,eAAe,KAAK,cAAc,KAAK,IAAI;EAC3C,WAAW,KAAK,UAAU,KAAK,IAAI;EACnC,aAAa,KAAK,YAAY,KAAK,IAAI;CACzC;CAEA,MAAM,IAAI,MAAM,MAAM;CACtB,OAAO;AACT;AAEA,MAAa,UAAU,OAAO;AAC9B,MAAa,YAAY,OAAO;AAChC,MAAa,cAAc,OAAO;AAGlC,IAAA,0CAAe;CAAE;CAAgB;CAAS;CAAW;AAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"type":"module","version":"11.
|
|
1
|
+
{"type":"module","version":"11.14.0","sideEffects":false}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { wrapRequestHandlerWithInit } from "./wrapRequestHandlerWithInit.js";
|
|
2
|
+
import { init } from "./sdk.js";
|
|
3
|
+
import { setAsyncLocalStorageAsyncContextStrategy } from "@sentry/server-utils/no-diagnostic-channels";
|
|
4
|
+
// src/pages-plugin.ts
|
|
5
5
|
function sentryPagesPlugin(handlerOrOptions) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
setAsyncLocalStorageAsyncContextStrategy();
|
|
7
|
+
return (context) => {
|
|
8
|
+
if (context.request.method === "OPTIONS" || context.request.method === "HEAD") return context.next();
|
|
9
|
+
const options = typeof handlerOrOptions === "function" ? handlerOrOptions(context) : handlerOrOptions;
|
|
10
|
+
const executionContext = {
|
|
11
|
+
...context,
|
|
12
|
+
props: {}
|
|
13
|
+
};
|
|
14
|
+
return wrapRequestHandlerWithInit({
|
|
15
|
+
options,
|
|
16
|
+
request: context.request,
|
|
17
|
+
context: executionContext
|
|
18
|
+
}, () => context.next(), init);
|
|
19
|
+
};
|
|
19
20
|
}
|
|
20
|
-
|
|
21
21
|
export { sentryPagesPlugin };
|
|
22
|
-
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=pages-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pages-plugin.js","sources":["../../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\nimport { init } from './sdk';\nimport type { StrictCloudflareOptions } from './types';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\n// Overloads rather than a union parameter: TypeScript does not infer `O` out of a union member,\n// so a union signature falls back to the default and the unknown-key check never runs. The object\n// overload stays on plain `CloudflareOptions` — a direct object literal is still excess property\n// checked, and a callback cannot match it.\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n O = unknown,\n>(\n handler: (context: EventPluginContext<Env, Params, Data, PluginParams>) => StrictCloudflareOptions<O>,\n): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(options: CloudflareOptions): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n if (context.request.method === 'OPTIONS' || context.request.method === 'HEAD') {\n return context.next();\n }\n\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n // A Pages `EventPluginContext` is not a Workers `ExecutionContext`, but `wrapRequestHandler` only\n // uses `waitUntil` and a `'storage' in context` check, both of which this satisfies.\n const executionContext = { ...context, props: {} } as unknown as ExecutionContextCompat;\n return wrapRequestHandlerWithInit(\n { options, request: context.request, context: executionContext },\n () => context.next(),\n init,\n );\n };\n}\n"],"
|
|
1
|
+
{"version":3,"file":"pages-plugin.js","names":[],"sources":["../../../src/pages-plugin.ts"],"sourcesContent":["import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\nimport type { CloudflareOptions } from './client';\nimport type { ExecutionContextCompat } from './executionContext';\nimport { wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\nimport { init } from './sdk';\nimport type { StrictCloudflareOptions } from './types';\n\n/**\n * Plugin middleware for Cloudflare Pages.\n *\n * Initializes the SDK and wraps cloudflare pages requests with SDK instrumentation.\n *\n * @example Simple usage\n *\n * ```javascript\n * // functions/_middleware.js\n * import * as Sentry from '@sentry/cloudflare';\n *\n * export const onRequest = Sentry.sentryPagesPlugin({\n * dsn: process.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * });\n * ```\n *\n * @example Usage with handler function to access context for environmental variables\n *\n * ```javascript\n * import * as Sentry from '@sentry/cloudflare';\n *\n * const const onRequest = Sentry.sentryPagesPlugin((context) => ({\n * dsn: context.env.SENTRY_DSN,\n * tracesSampleRate: 1.0,\n * })\n * ```\n *\n * @param handlerOrOptions Configuration options or a function that returns configuration options.\n * @returns A plugin function that can be used in Cloudflare Pages.\n */\n// Overloads rather than a union parameter: TypeScript does not infer `O` out of a union member,\n// so a union signature falls back to the default and the unknown-key check never runs. The object\n// overload stays on plain `CloudflareOptions` — a direct object literal is still excess property\n// checked, and a callback cannot match it.\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n O = unknown,\n>(\n handler: (context: EventPluginContext<Env, Params, Data, PluginParams>) => StrictCloudflareOptions<O>,\n): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(options: CloudflareOptions): PagesPluginFunction<Env, Params, Data, PluginParams>;\nexport function sentryPagesPlugin<\n // oxlint-disable-next-line typescript/no-explicit-any\n Env = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n Params extends string = any,\n Data extends Record<string, unknown> = Record<string, unknown>,\n // Although it is not ideal to use `any` here, it makes usage more flexible for different setups.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n PluginParams = any,\n>(\n handlerOrOptions:\n | CloudflareOptions\n | ((context: EventPluginContext<Env, Params, Data, PluginParams>) => CloudflareOptions),\n): PagesPluginFunction<Env, Params, Data, PluginParams> {\n setAsyncLocalStorageAsyncContextStrategy();\n return context => {\n if (context.request.method === 'OPTIONS' || context.request.method === 'HEAD') {\n return context.next();\n }\n\n const options = typeof handlerOrOptions === 'function' ? handlerOrOptions(context) : handlerOrOptions;\n // A Pages `EventPluginContext` is not a Workers `ExecutionContext`, but `wrapRequestHandler` only\n // uses `waitUntil` and a `'storage' in context` check, both of which this satisfies.\n const executionContext = { ...context, props: {} } as unknown as ExecutionContextCompat;\n return wrapRequestHandlerWithInit(\n { options, request: context.request, context: executionContext },\n () => context.next(),\n init,\n );\n };\n}\n"],"mappings":";;;;AA+DA,SAAgB,kBAUd,kBAGsD;CACtD,yCAAyC;CACzC,QAAO,YAAW;EAChB,IAAI,QAAQ,QAAQ,WAAW,aAAa,QAAQ,QAAQ,WAAW,QACrE,OAAO,QAAQ,KAAK;EAGtB,MAAM,UAAU,OAAO,qBAAqB,aAAa,iBAAiB,OAAO,IAAI;EAGrF,MAAM,mBAAmB;GAAE,GAAG;GAAS,OAAO,CAAC;EAAE;EACjD,OAAO,2BACL;GAAE;GAAS,SAAS,QAAQ;GAAS,SAAS;EAAiB,SACzD,QAAQ,KAAK,GACnB,IACF;CACF;AACF"}
|
package/build/esm/dev/request.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { initBaseSdk } from
|
|
2
|
-
import { wrapRequestHandlerWithInit } from
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { initBaseSdk } from "./baseSdk.js";
|
|
2
|
+
import { wrapRequestHandlerWithInit } from "./wrapRequestHandlerWithInit.js";
|
|
3
|
+
import { httpServerIntegration } from "./integrations/httpServer.js";
|
|
4
|
+
// src/request.ts
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a cloudflare request handler in Sentry instrumentation.
|
|
7
|
+
*
|
|
8
|
+
* The client uses the same default integrations as `init`, without setting up an OpenTelemetry
|
|
9
|
+
* tracer provider. This entry point also works on runtimes that cannot enable the `nodejs_compat`
|
|
10
|
+
* compatibility flag, such as Shopify Oxygen.
|
|
11
|
+
*/
|
|
5
12
|
function wrapRequestHandler(wrapperOptions, handler) {
|
|
6
|
-
|
|
13
|
+
return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);
|
|
7
14
|
}
|
|
15
|
+
export { httpServerIntegration, wrapRequestHandler };
|
|
8
16
|
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=request.js.map
|
|
17
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sources":["../../../src/request.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareOptions } from './client';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation.\n *\n * The client uses the same default integrations as `init`, without setting up an OpenTelemetry\n * tracer provider. This entry point also works on runtimes that cannot enable the `nodejs_compat`\n * compatibility flag, such as Shopify Oxygen.\n */\nexport function wrapRequestHandler(\n wrapperOptions: Omit<RequestHandlerWrapperOptions, 'options'> & {\n // `enableOpenTelemetrySetup` is only honored by `init` from `sdk.ts`; this entry point\n // initializes the SDK via `initBaseSdk`, where setting it would have no effect.\n options: Omit<CloudflareOptions, 'enableOpenTelemetrySetup'>;\n },\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);\n}\n\nexport { httpServerIntegration } from './integrations/httpServer';\n"],"
|
|
1
|
+
{"version":3,"file":"request.js","names":[],"sources":["../../../src/request.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareOptions } from './client';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n/**\n * Wraps a cloudflare request handler in Sentry instrumentation.\n *\n * The client uses the same default integrations as `init`, without setting up an OpenTelemetry\n * tracer provider. This entry point also works on runtimes that cannot enable the `nodejs_compat`\n * compatibility flag, such as Shopify Oxygen.\n */\nexport function wrapRequestHandler(\n wrapperOptions: Omit<RequestHandlerWrapperOptions, 'options'> & {\n // `enableOpenTelemetrySetup` is only honored by `init` from `sdk.ts`; this entry point\n // initializes the SDK via `initBaseSdk`, where setting it would have no effect.\n options: Omit<CloudflareOptions, 'enableOpenTelemetrySetup'>;\n },\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, initBaseSdk);\n}\n\nexport { httpServerIntegration } from './integrations/httpServer';\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,mBACd,gBAKA,SACmB;CACnB,OAAO,2BAA2B,gBAAgB,SAAS,WAAW;AACxE"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { CLOUD_PROVIDER } from
|
|
2
|
-
|
|
1
|
+
import { CLOUD_PROVIDER } from "@sentry/conventions/attributes";
|
|
2
|
+
// src/scope-utils.ts
|
|
3
|
+
/**
|
|
4
|
+
* Set cloud resource context on scope.
|
|
5
|
+
*/
|
|
3
6
|
function addCloudResourceContext(scope) {
|
|
4
|
-
|
|
5
|
-
[CLOUD_PROVIDER]: "cloudflare"
|
|
6
|
-
});
|
|
7
|
+
scope.setContext("cloud_resource", { [CLOUD_PROVIDER]: "cloudflare" });
|
|
7
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Set culture context on scope
|
|
11
|
+
*/
|
|
8
12
|
function addCultureContext(scope, cf) {
|
|
9
|
-
|
|
10
|
-
timezone: cf.timezone
|
|
11
|
-
});
|
|
13
|
+
scope.setContext("culture", { timezone: cf.timezone });
|
|
12
14
|
}
|
|
13
|
-
|
|
14
15
|
export { addCloudResourceContext, addCultureContext };
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=scope-utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-utils.js","sources":["../../../src/scope-utils.ts"],"sourcesContent":["import { CLOUD_PROVIDER } from '@sentry/conventions/attributes';\nimport type { CfProperties, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport type { Scope } from '@sentry/core';\n\n/**\n * Set cloud resource context on scope.\n */\nexport function addCloudResourceContext(scope: Scope): void {\n scope.setContext('cloud_resource', {\n [CLOUD_PROVIDER]: 'cloudflare',\n });\n}\n\n/**\n * Set culture context on scope\n */\nexport function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties | CfProperties): void {\n scope.setContext('culture', {\n timezone: cf.timezone,\n });\n}\n"],"
|
|
1
|
+
{"version":3,"file":"scope-utils.js","names":[],"sources":["../../../src/scope-utils.ts"],"sourcesContent":["import { CLOUD_PROVIDER } from '@sentry/conventions/attributes';\nimport type { CfProperties, IncomingRequestCfProperties } from '@cloudflare/workers-types';\nimport type { Scope } from '@sentry/core';\n\n/**\n * Set cloud resource context on scope.\n */\nexport function addCloudResourceContext(scope: Scope): void {\n scope.setContext('cloud_resource', {\n [CLOUD_PROVIDER]: 'cloudflare',\n });\n}\n\n/**\n * Set culture context on scope\n */\nexport function addCultureContext(scope: Scope, cf: IncomingRequestCfProperties | CfProperties): void {\n scope.setContext('culture', {\n timezone: cf.timezone,\n });\n}\n"],"mappings":";;;;;AAOA,SAAgB,wBAAwB,OAAoB;CAC1D,MAAM,WAAW,kBAAkB,GAChC,iBAAiB,aACpB,CAAC;AACH;;;;AAKA,SAAgB,kBAAkB,OAAc,IAAsD;CACpG,MAAM,WAAW,WAAW,EAC1B,UAAU,GAAG,SACf,CAAC;AACH"}
|
package/build/esm/dev/sdk.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import { initBaseSdk } from
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { getDefaultIntegrations, initBaseSdk } from "./baseSdk.js";
|
|
2
|
+
import { setupOpenTelemetryTracer } from "./opentelemetry/tracer.js";
|
|
3
|
+
import { wrapRequestHandlerWithInit } from "./wrapRequestHandlerWithInit.js";
|
|
4
|
+
import "./clientCache.js";
|
|
5
|
+
// src/sdk.ts
|
|
6
|
+
/**
|
|
7
|
+
* Initializes the cloudflare SDK.
|
|
8
|
+
*/
|
|
6
9
|
function init(options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
return initBaseSdk(options);
|
|
10
|
+
options.enableOpenTelemetrySetup ?? (options.enableOpenTelemetrySetup = false);
|
|
11
|
+
if (options.enableOpenTelemetrySetup) setupOpenTelemetryTracer();
|
|
12
|
+
return initBaseSdk(options);
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* `wrapRequestHandler` backed by `init`, so the request honors `enableOpenTelemetrySetup`. The
|
|
16
|
+
* `@sentry/cloudflare/request` variant deliberately skips it to stay usable without `nodejs_compat`.
|
|
17
|
+
*
|
|
18
|
+
* For framework SDKs building on the main entry point, e.g. SvelteKit, whose OpenTelemetry spans
|
|
19
|
+
* need the tracer provider.
|
|
20
|
+
*
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
13
23
|
function _INTERNAL_wrapRequestHandler(wrapperOptions, handler) {
|
|
14
|
-
|
|
24
|
+
return wrapRequestHandlerWithInit(wrapperOptions, handler, init);
|
|
15
25
|
}
|
|
26
|
+
export { _INTERNAL_wrapRequestHandler, getDefaultIntegrations, init };
|
|
16
27
|
|
|
17
|
-
|
|
18
|
-
//# sourceMappingURL=sdk.js.map
|
|
28
|
+
//# sourceMappingURL=sdk.js.map
|
package/build/esm/dev/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sources":["../../../src/sdk.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareClient, CloudflareOptions } from './client';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n// Test-only helper, re-exported here so tests can reset the global client cache.\nexport { _clearGlobalClientCache } from './clientCache';\n\nexport { getDefaultIntegrations } from './baseSdk';\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n // Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer\n // provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.\n options.enableOpenTelemetrySetup ??= false;\n\n // Opt-in only: when `enableOpenTelemetrySetup` is `true`, set up a custom trace provider so spans\n // emitted via `@opentelemetry/api` are captured by Sentry. See the option's docs for the caveats.\n if (options.enableOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initBaseSdk(options);\n}\n\n/**\n * `wrapRequestHandler` backed by `init`, so the request honors `enableOpenTelemetrySetup`. The\n * `@sentry/cloudflare/request` variant deliberately skips it to stay usable without `nodejs_compat`.\n *\n * For framework SDKs building on the main entry point, e.g. SvelteKit, whose OpenTelemetry spans\n * need the tracer provider.\n *\n * @internal\n */\nexport function _INTERNAL_wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, init);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"sdk.js","names":[],"sources":["../../../src/sdk.ts"],"sourcesContent":["import { initBaseSdk } from './baseSdk';\nimport type { CloudflareClient, CloudflareOptions } from './client';\nimport { setupOpenTelemetryTracer } from './opentelemetry/tracer';\nimport { type RequestHandlerWrapperOptions, wrapRequestHandlerWithInit } from './wrapRequestHandlerWithInit';\n\n// Test-only helper, re-exported here so tests can reset the global client cache.\nexport { _clearGlobalClientCache } from './clientCache';\n\nexport { getDefaultIntegrations } from './baseSdk';\n\n/**\n * Initializes the cloudflare SDK.\n */\nexport function init(options: CloudflareOptions): CloudflareClient | undefined {\n // Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer\n // provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.\n options.enableOpenTelemetrySetup ??= false;\n\n // Opt-in only: when `enableOpenTelemetrySetup` is `true`, set up a custom trace provider so spans\n // emitted via `@opentelemetry/api` are captured by Sentry. See the option's docs for the caveats.\n if (options.enableOpenTelemetrySetup) {\n setupOpenTelemetryTracer();\n }\n\n return initBaseSdk(options);\n}\n\n/**\n * `wrapRequestHandler` backed by `init`, so the request honors `enableOpenTelemetrySetup`. The\n * `@sentry/cloudflare/request` variant deliberately skips it to stay usable without `nodejs_compat`.\n *\n * For framework SDKs building on the main entry point, e.g. SvelteKit, whose OpenTelemetry spans\n * need the tracer provider.\n *\n * @internal\n */\nexport function _INTERNAL_wrapRequestHandler(\n wrapperOptions: RequestHandlerWrapperOptions,\n handler: (...args: unknown[]) => Response | Promise<Response>,\n): Promise<Response> {\n return wrapRequestHandlerWithInit(wrapperOptions, handler, init);\n}\n"],"mappings":";;;;;;;;AAaA,SAAgB,KAAK,SAA0D;CAG7E,QAAQ,6BAAR,QAAQ,2BAA6B;CAIrC,IAAI,QAAQ,0BACV,yBAAyB;CAG3B,OAAO,YAAY,OAAO;AAC5B;;;;;;;;;;AAWA,SAAgB,6BACd,gBACA,SACmB;CACnB,OAAO,2BAA2B,gBAAgB,SAAS,IAAI;AACjE"}
|
|
@@ -1,88 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { SENTRY_BUFFER_FULL_ERROR, createTransport, suppressTracing } from "@sentry/core";
|
|
2
|
+
// src/transport.ts
|
|
3
|
+
/**
|
|
4
|
+
* How many payloads the buffer holds before it starts rejecting new ones.
|
|
5
|
+
*
|
|
6
|
+
* With `cacheClient` a single client is reused across an isolate's invocations, so one buffer now has to absorb
|
|
7
|
+
* the payloads of many invocations rather than one. 256 is the size that held up under load testing that scenario.
|
|
8
|
+
*/
|
|
3
9
|
const DEFAULT_TRANSPORT_BUFFER_SIZE = 256;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* This is a modified promise buffer that collects tasks until drain is called.
|
|
12
|
+
* We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests
|
|
13
|
+
* and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.
|
|
14
|
+
*
|
|
15
|
+
* A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the
|
|
16
|
+
* SDK can send for a given edge function invocation.
|
|
17
|
+
*/
|
|
18
|
+
var IsolatedPromiseBuffer = class {
|
|
19
|
+
constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {
|
|
20
|
+
this.$ = [];
|
|
21
|
+
this._taskProducers = [];
|
|
22
|
+
this._bufferSize = _bufferSize;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @inheritdoc
|
|
26
|
+
*/
|
|
27
|
+
add(taskProducer) {
|
|
28
|
+
if (this._taskProducers.length >= this._bufferSize) return Promise.reject(SENTRY_BUFFER_FULL_ERROR);
|
|
29
|
+
this._taskProducers.push(taskProducer);
|
|
30
|
+
return Promise.resolve({});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @inheritdoc
|
|
34
|
+
*/
|
|
35
|
+
drain(timeout) {
|
|
36
|
+
const oldTaskProducers = [...this._taskProducers];
|
|
37
|
+
this._taskProducers = [];
|
|
38
|
+
const drainController = new AbortController();
|
|
39
|
+
this.drainSignal = drainController.signal;
|
|
40
|
+
const tasks = oldTaskProducers.map((taskProducer) => {
|
|
41
|
+
try {
|
|
42
|
+
return taskProducer();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return Promise.reject(error);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
this.drainSignal = void 0;
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
const timer = setTimeout(() => {
|
|
50
|
+
if (timeout && timeout > 0) {
|
|
51
|
+
drainController.abort();
|
|
52
|
+
resolve(false);
|
|
53
|
+
}
|
|
54
|
+
}, timeout);
|
|
55
|
+
Promise.all(tasks.map((task) => task.then(null, () => {}))).then(() => {
|
|
56
|
+
clearTimeout(timer);
|
|
57
|
+
resolve(true);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Creates a Transport that uses the native fetch API to send events to Sentry.
|
|
64
|
+
*/
|
|
55
65
|
function makeCloudflareTransport(options) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return createTransport(options, makeRequest, buffer);
|
|
66
|
+
const buffer = new IsolatedPromiseBuffer(options.bufferSize);
|
|
67
|
+
function makeRequest(request) {
|
|
68
|
+
const drainSignal = buffer.drainSignal;
|
|
69
|
+
const callerSignal = options.fetchOptions?.signal ?? void 0;
|
|
70
|
+
const signal = drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : drainSignal ?? callerSignal;
|
|
71
|
+
const requestOptions = {
|
|
72
|
+
body: request.body,
|
|
73
|
+
method: "POST",
|
|
74
|
+
headers: options.headers,
|
|
75
|
+
...options.fetchOptions,
|
|
76
|
+
...signal ? { signal } : {}
|
|
77
|
+
};
|
|
78
|
+
return suppressTracing(() => {
|
|
79
|
+
return (options.fetch ?? fetch)(options.url, requestOptions).then(async (response) => {
|
|
80
|
+
try {
|
|
81
|
+
await response.text();
|
|
82
|
+
} catch {}
|
|
83
|
+
return {
|
|
84
|
+
statusCode: response.status,
|
|
85
|
+
headers: {
|
|
86
|
+
"x-sentry-rate-limits": response.headers.get("X-Sentry-Rate-Limits"),
|
|
87
|
+
"retry-after": response.headers.get("Retry-After")
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return createTransport(options, makeRequest, buffer);
|
|
85
94
|
}
|
|
86
|
-
|
|
87
95
|
export { IsolatedPromiseBuffer, makeCloudflareTransport };
|
|
88
|
-
|
|
96
|
+
|
|
97
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sources":["../../../src/transport.ts"],"sourcesContent":["import type { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/core';\nimport { createTransport, SENTRY_BUFFER_FULL_ERROR, suppressTracing } from '@sentry/core';\n\nexport interface CloudflareTransportOptions extends BaseTransportOptions {\n /** Custom fetch function to use. This allows usage of things like Workers VPC */\n fetch?: typeof fetch;\n /** Fetch API init parameters. */\n fetchOptions?: RequestInit;\n}\n\n/**\n * How many payloads the buffer holds before it starts rejecting new ones.\n *\n * With `cacheClient` a single client is reused across an isolate's invocations, so one buffer now has to absorb\n * the payloads of many invocations rather than one. 256 is the size that held up under load testing that scenario.\n */\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 256;\n\n/**\n * This is a modified promise buffer that collects tasks until drain is called.\n * We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests\n * and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.\n *\n * A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the\n * SDK can send for a given edge function invocation.\n */\nexport class IsolatedPromiseBuffer {\n // We just have this field because the promise buffer interface requires it.\n // If we ever remove it from the interface we should also remove it here.\n public $: Array<PromiseLike<TransportMakeRequestResponse>>;\n\n /**\n * Abort signal of the drain that is starting its requests. It is set only while `drain()` runs the task\n * producers, so a request reads the signal of the drain that sends it.\n */\n public drainSignal: AbortSignal | undefined;\n\n private _taskProducers: (() => PromiseLike<TransportMakeRequestResponse>)[];\n\n private readonly _bufferSize: number;\n\n public constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {\n this.$ = [];\n this._taskProducers = [];\n this._bufferSize = _bufferSize;\n }\n\n /**\n * @inheritdoc\n */\n public add(taskProducer: () => PromiseLike<TransportMakeRequestResponse>): PromiseLike<TransportMakeRequestResponse> {\n if (this._taskProducers.length >= this._bufferSize) {\n return Promise.reject(SENTRY_BUFFER_FULL_ERROR);\n }\n\n this._taskProducers.push(taskProducer);\n return Promise.resolve({});\n }\n\n /**\n * @inheritdoc\n */\n public drain(timeout?: number): PromiseLike<boolean> {\n const oldTaskProducers = [...this._taskProducers];\n this._taskProducers = [];\n\n const drainController = new AbortController();\n this.drainSignal = drainController.signal;\n const tasks = oldTaskProducers.map(taskProducer => {\n // A request that throws synchronously, such as a custom `fetch`, must not stop the other requests\n // or throw into the caller.\n try {\n return taskProducer();\n } catch (error) {\n return Promise.reject(error);\n }\n });\n this.drainSignal = undefined;\n\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\n // Requests still pending when the drain times out are aborted. Otherwise Cloudflare keeps them\n // until it cancels the invocation's `waitUntil` work and logs a warning.\n drainController.abort();\n resolve(false);\n }\n }, timeout);\n\n // This cannot reject\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all(\n tasks.map(task =>\n task.then(null, () => {\n // catch all failed requests\n }),\n ),\n ).then(() => {\n // resolve to true if all fetch requests settled\n clearTimeout(timer);\n resolve(true);\n });\n });\n }\n}\n\n/**\n * Creates a Transport that uses the native fetch API to send events to Sentry.\n */\nexport function makeCloudflareTransport(options: CloudflareTransportOptions): Transport {\n const buffer = new IsolatedPromiseBuffer(options.bufferSize);\n\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const drainSignal = buffer.drainSignal;\n const callerSignal = options.fetchOptions?.signal ?? undefined;\n const signal =\n drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : (drainSignal ?? callerSignal);\n\n const requestOptions: RequestInit = {\n body: request.body as BodyInit,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\n ...(signal ? { signal } : {}),\n };\n\n return suppressTracing(() => {\n return (options.fetch ?? fetch)(options.url, requestOptions).then(async response => {\n // Consume the response body to satisfy Cloudflare Workers' fetch requirements.\n // The runtime requires all fetch response bodies to be read or explicitly canceled\n // to prevent connection stalls and potential deadlocks. We read the body as text\n // even though we don't use the content, as Sentry's response information is in the headers.\n // See: https://github.com/getsentry/sentry-javascript/issues/18534\n try {\n await response.text();\n } catch {\n // no-op\n }\n\n return {\n statusCode: response.status,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n };\n });\n });\n }\n\n return createTransport(options, makeRequest, buffer);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"transport.js","names":[],"sources":["../../../src/transport.ts"],"sourcesContent":["import type { BaseTransportOptions, Transport, TransportMakeRequestResponse, TransportRequest } from '@sentry/core';\nimport { createTransport, SENTRY_BUFFER_FULL_ERROR, suppressTracing } from '@sentry/core';\n\nexport interface CloudflareTransportOptions extends BaseTransportOptions {\n /** Custom fetch function to use. This allows usage of things like Workers VPC */\n fetch?: typeof fetch;\n /** Fetch API init parameters. */\n fetchOptions?: RequestInit;\n}\n\n/**\n * How many payloads the buffer holds before it starts rejecting new ones.\n *\n * With `cacheClient` a single client is reused across an isolate's invocations, so one buffer now has to absorb\n * the payloads of many invocations rather than one. 256 is the size that held up under load testing that scenario.\n */\nconst DEFAULT_TRANSPORT_BUFFER_SIZE = 256;\n\n/**\n * This is a modified promise buffer that collects tasks until drain is called.\n * We need this in the edge runtime because edge function invocations may not share I/O objects, like fetch requests\n * and responses, and the normal PromiseBuffer inherently buffers stuff inbetween incoming requests.\n *\n * A limitation we need to be aware of is that DEFAULT_TRANSPORT_BUFFER_SIZE is the maximum amount of payloads the\n * SDK can send for a given edge function invocation.\n */\nexport class IsolatedPromiseBuffer {\n // We just have this field because the promise buffer interface requires it.\n // If we ever remove it from the interface we should also remove it here.\n public $: Array<PromiseLike<TransportMakeRequestResponse>>;\n\n /**\n * Abort signal of the drain that is starting its requests. It is set only while `drain()` runs the task\n * producers, so a request reads the signal of the drain that sends it.\n */\n public drainSignal: AbortSignal | undefined;\n\n private _taskProducers: (() => PromiseLike<TransportMakeRequestResponse>)[];\n\n private readonly _bufferSize: number;\n\n public constructor(_bufferSize = DEFAULT_TRANSPORT_BUFFER_SIZE) {\n this.$ = [];\n this._taskProducers = [];\n this._bufferSize = _bufferSize;\n }\n\n /**\n * @inheritdoc\n */\n public add(taskProducer: () => PromiseLike<TransportMakeRequestResponse>): PromiseLike<TransportMakeRequestResponse> {\n if (this._taskProducers.length >= this._bufferSize) {\n return Promise.reject(SENTRY_BUFFER_FULL_ERROR);\n }\n\n this._taskProducers.push(taskProducer);\n return Promise.resolve({});\n }\n\n /**\n * @inheritdoc\n */\n public drain(timeout?: number): PromiseLike<boolean> {\n const oldTaskProducers = [...this._taskProducers];\n this._taskProducers = [];\n\n const drainController = new AbortController();\n this.drainSignal = drainController.signal;\n const tasks = oldTaskProducers.map(taskProducer => {\n // A request that throws synchronously, such as a custom `fetch`, must not stop the other requests\n // or throw into the caller.\n try {\n return taskProducer();\n } catch (error) {\n return Promise.reject(error);\n }\n });\n this.drainSignal = undefined;\n\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n if (timeout && timeout > 0) {\n // Requests still pending when the drain times out are aborted. Otherwise Cloudflare keeps them\n // until it cancels the invocation's `waitUntil` work and logs a warning.\n drainController.abort();\n resolve(false);\n }\n }, timeout);\n\n // This cannot reject\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.all(\n tasks.map(task =>\n task.then(null, () => {\n // catch all failed requests\n }),\n ),\n ).then(() => {\n // resolve to true if all fetch requests settled\n clearTimeout(timer);\n resolve(true);\n });\n });\n }\n}\n\n/**\n * Creates a Transport that uses the native fetch API to send events to Sentry.\n */\nexport function makeCloudflareTransport(options: CloudflareTransportOptions): Transport {\n const buffer = new IsolatedPromiseBuffer(options.bufferSize);\n\n function makeRequest(request: TransportRequest): PromiseLike<TransportMakeRequestResponse> {\n const drainSignal = buffer.drainSignal;\n const callerSignal = options.fetchOptions?.signal ?? undefined;\n const signal =\n drainSignal && callerSignal ? AbortSignal.any([drainSignal, callerSignal]) : (drainSignal ?? callerSignal);\n\n const requestOptions: RequestInit = {\n body: request.body as BodyInit,\n method: 'POST',\n headers: options.headers,\n ...options.fetchOptions,\n ...(signal ? { signal } : {}),\n };\n\n return suppressTracing(() => {\n return (options.fetch ?? fetch)(options.url, requestOptions).then(async response => {\n // Consume the response body to satisfy Cloudflare Workers' fetch requirements.\n // The runtime requires all fetch response bodies to be read or explicitly canceled\n // to prevent connection stalls and potential deadlocks. We read the body as text\n // even though we don't use the content, as Sentry's response information is in the headers.\n // See: https://github.com/getsentry/sentry-javascript/issues/18534\n try {\n await response.text();\n } catch {\n // no-op\n }\n\n return {\n statusCode: response.status,\n headers: {\n 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'),\n 'retry-after': response.headers.get('Retry-After'),\n },\n };\n });\n });\n }\n\n return createTransport(options, makeRequest, buffer);\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,gCAAgC;;;;;;;;;AAUtC,IAAa,wBAAb,MAAmC;CAe1B,YAAY,cAAc,+BAA+B;EAC9D,KAAK,IAAI,CAAC;EACV,KAAK,iBAAiB,CAAC;EACvB,KAAK,cAAc;CACrB;;;;CAKO,IAAI,cAA0G;EACnH,IAAI,KAAK,eAAe,UAAU,KAAK,aACrC,OAAO,QAAQ,OAAO,wBAAwB;EAGhD,KAAK,eAAe,KAAK,YAAY;EACrC,OAAO,QAAQ,QAAQ,CAAC,CAAC;CAC3B;;;;CAKO,MAAM,SAAwC;EACnD,MAAM,mBAAmB,CAAC,GAAG,KAAK,cAAc;EAChD,KAAK,iBAAiB,CAAC;EAEvB,MAAM,kBAAkB,IAAI,gBAAgB;EAC5C,KAAK,cAAc,gBAAgB;EACnC,MAAM,QAAQ,iBAAiB,KAAI,iBAAgB;GAGjD,IAAI;IACF,OAAO,aAAa;GACtB,SAAS,OAAO;IACd,OAAO,QAAQ,OAAO,KAAK;GAC7B;EACF,CAAC;EACD,KAAK,cAAc,KAAA;EAEnB,OAAO,IAAI,SAAQ,YAAW;GAC5B,MAAM,QAAQ,iBAAiB;IAC7B,IAAI,WAAW,UAAU,GAAG;KAG1B,gBAAgB,MAAM;KACtB,QAAQ,KAAK;IACf;GACF,GAAG,OAAO;GAIV,QAAQ,IACN,MAAM,KAAI,SACR,KAAK,KAAK,YAAY,CAEtB,CAAC,CACH,CACF,CAAC,CAAC,WAAW;IAEX,aAAa,KAAK;IAClB,QAAQ,IAAI;GACd,CAAC;EACH,CAAC;CACH;AACF;;;;AAKA,SAAgB,wBAAwB,SAAgD;CACtF,MAAM,SAAS,IAAI,sBAAsB,QAAQ,UAAU;CAE3D,SAAS,YAAY,SAAsE;EACzF,MAAM,cAAc,OAAO;EAC3B,MAAM,eAAe,QAAQ,cAAc,UAAU,KAAA;EACrD,MAAM,SACJ,eAAe,eAAe,YAAY,IAAI,CAAC,aAAa,YAAY,CAAC,IAAK,eAAe;EAE/F,MAAM,iBAA8B;GAClC,MAAM,QAAQ;GACd,QAAQ;GACR,SAAS,QAAQ;GACjB,GAAG,QAAQ;GACX,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC7B;EAEA,OAAO,sBAAsB;GAC3B,QAAQ,QAAQ,SAAS,MAAA,CAAO,QAAQ,KAAK,cAAc,CAAC,CAAC,KAAK,OAAM,aAAY;IAMlF,IAAI;KACF,MAAM,SAAS,KAAK;IACtB,QAAQ,CAER;IAEA,OAAO;KACL,YAAY,SAAS;KACrB,SAAS;MACP,wBAAwB,SAAS,QAAQ,IAAI,sBAAsB;MACnE,eAAe,SAAS,QAAQ,IAAI,aAAa;KACnD;IACF;GACF,CAAC;EACH,CAAC;CACH;CAEA,OAAO,gBAAgB,SAAS,aAAa,MAAM;AACrD"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { getAsyncContextStrategy, getMainCarrier } from
|
|
2
|
-
import { setAsyncLocalStorageAsyncContextStrategy } from
|
|
3
|
-
|
|
1
|
+
import { getAsyncContextStrategy, getMainCarrier } from "@sentry/core";
|
|
2
|
+
import { setAsyncLocalStorageAsyncContextStrategy } from "@sentry/server-utils/no-diagnostic-channels";
|
|
3
|
+
// src/utils/asyncContextStrategy.ts
|
|
4
|
+
/**
|
|
5
|
+
* Installs the AsyncLocalStorage strategy unless an OpenTelemetry strategy is installed. Both use the same storage,
|
|
6
|
+
* so a switch during a request breaks it (#24603).
|
|
7
|
+
*/
|
|
4
8
|
function setAsyncLocalStorageAsyncContextStrategyForWorker() {
|
|
5
|
-
|
|
6
|
-
setAsyncLocalStorageAsyncContextStrategy();
|
|
7
|
-
}
|
|
9
|
+
if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) setAsyncLocalStorageAsyncContextStrategy();
|
|
8
10
|
}
|
|
9
|
-
|
|
10
11
|
export { setAsyncLocalStorageAsyncContextStrategyForWorker };
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=asyncContextStrategy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncContextStrategy.js","sources":["../../../../src/utils/asyncContextStrategy.ts"],"sourcesContent":["import { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\n\n/**\n * Installs the AsyncLocalStorage strategy unless an OpenTelemetry strategy is installed. Both use the same storage,\n * so a switch during a request breaks it (#24603).\n */\nexport function setAsyncLocalStorageAsyncContextStrategyForWorker(): void {\n if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) {\n setAsyncLocalStorageAsyncContextStrategy();\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"asyncContextStrategy.js","names":[],"sources":["../../../../src/utils/asyncContextStrategy.ts"],"sourcesContent":["import { getAsyncContextStrategy, getMainCarrier } from '@sentry/core';\nimport { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils/no-diagnostic-channels';\n\n/**\n * Installs the AsyncLocalStorage strategy unless an OpenTelemetry strategy is installed. Both use the same storage,\n * so a switch during a request breaks it (#24603).\n */\nexport function setAsyncLocalStorageAsyncContextStrategyForWorker(): void {\n if (!getAsyncContextStrategy(getMainCarrier()).withActiveSpan) {\n setAsyncLocalStorageAsyncContextStrategy();\n }\n}\n"],"mappings":";;;;;;;AAOA,SAAgB,oDAA0D;CACxE,IAAI,CAAC,wBAAwB,eAAe,CAAC,CAAC,CAAC,gBAC7C,yCAAyC;AAE7C"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { matchesTracePropagationTargets } from
|
|
2
|
-
|
|
1
|
+
import { matchesTracePropagationTargets } from "@sentry/core";
|
|
2
|
+
// src/utils/bindingPropagation.ts
|
|
3
3
|
const PROPAGATE_TO_NONE = () => false;
|
|
4
|
+
/**
|
|
5
|
+
* Builds the per-binding predicate that decides whether a binding takes part in trace propagation.
|
|
6
|
+
*/
|
|
4
7
|
function createBindingPropagationResolver(bindings) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return (bindingName) => matchesTracePropagationTargets(bindingName, bindings, true);
|
|
8
|
+
if (!bindings?.length) return PROPAGATE_TO_NONE;
|
|
9
|
+
return (bindingName) => matchesTracePropagationTargets(bindingName, bindings, true);
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds the per-binding predicate that decides whether a binding takes part in RPC trace
|
|
13
|
+
* propagation.
|
|
14
|
+
*
|
|
15
|
+
* Callers only. Receivers continue an incoming trace whenever one arrives, so they have nothing to
|
|
16
|
+
* match against.
|
|
17
|
+
*/
|
|
10
18
|
function createRpcPropagationResolver(options) {
|
|
11
|
-
|
|
19
|
+
return createBindingPropagationResolver(options?.rpcTracePropagationBindings);
|
|
12
20
|
}
|
|
13
|
-
|
|
14
21
|
export { createBindingPropagationResolver, createRpcPropagationResolver };
|
|
15
|
-
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=bindingPropagation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindingPropagation.js","sources":["../../../../src/utils/bindingPropagation.ts"],"sourcesContent":["import { matchesTracePropagationTargets, type TracePropagationTargets } from '@sentry/core';\nimport type { CloudflareOptions } from '../client';\n\nconst PROPAGATE_TO_NONE = () => false;\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in trace propagation.\n */\nexport function createBindingPropagationResolver(\n bindings: TracePropagationTargets | undefined,\n): (bindingName: string) => boolean {\n if (!bindings?.length) {\n return PROPAGATE_TO_NONE;\n }\n\n // Strings must match a binding name exactly, without this, an entry of `DB` would also enable\n // propagation for a binding named `MY_DB`. Regular expressions still give pattern matching.\n return (bindingName: string) => matchesTracePropagationTargets(bindingName, bindings, true);\n}\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in RPC trace\n * propagation.\n *\n * Callers only. Receivers continue an incoming trace whenever one arrives, so they have nothing to\n * match against.\n */\nexport function createRpcPropagationResolver(options: CloudflareOptions | undefined): (bindingName: string) => boolean {\n return createBindingPropagationResolver(options?.rpcTracePropagationBindings);\n}\n"],"
|
|
1
|
+
{"version":3,"file":"bindingPropagation.js","names":[],"sources":["../../../../src/utils/bindingPropagation.ts"],"sourcesContent":["import { matchesTracePropagationTargets, type TracePropagationTargets } from '@sentry/core';\nimport type { CloudflareOptions } from '../client';\n\nconst PROPAGATE_TO_NONE = () => false;\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in trace propagation.\n */\nexport function createBindingPropagationResolver(\n bindings: TracePropagationTargets | undefined,\n): (bindingName: string) => boolean {\n if (!bindings?.length) {\n return PROPAGATE_TO_NONE;\n }\n\n // Strings must match a binding name exactly, without this, an entry of `DB` would also enable\n // propagation for a binding named `MY_DB`. Regular expressions still give pattern matching.\n return (bindingName: string) => matchesTracePropagationTargets(bindingName, bindings, true);\n}\n\n/**\n * Builds the per-binding predicate that decides whether a binding takes part in RPC trace\n * propagation.\n *\n * Callers only. Receivers continue an incoming trace whenever one arrives, so they have nothing to\n * match against.\n */\nexport function createRpcPropagationResolver(options: CloudflareOptions | undefined): (bindingName: string) => boolean {\n return createBindingPropagationResolver(options?.rpcTracePropagationBindings);\n}\n"],"mappings":";;AAGA,MAAM,0BAA0B;;;;AAKhC,SAAgB,iCACd,UACkC;CAClC,IAAI,CAAC,UAAU,QACb,OAAO;CAKT,QAAQ,gBAAwB,+BAA+B,aAAa,UAAU,IAAI;AAC5F;;;;;;;;AASA,SAAgB,6BAA6B,SAA0E;CACrH,OAAO,iCAAiC,SAAS,2BAA2B;AAC9E"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { _INTERNAL_safeMathRandom, getCurrentScope, hasSpansEnabled, isContinuingTrace } from "@sentry/core";
|
|
2
|
+
// src/utils/cloudflareTrace.ts
|
|
3
|
+
const TRACE_ID_REGEXP = /^(?!0{32})[0-9a-f]{32}$/;
|
|
4
|
+
const SPAN_ID_REGEXP = /^(?!0{16})[0-9a-f]{16}$/;
|
|
5
|
+
/**
|
|
6
|
+
* Sets the propagation context of the current scope to the Cloudflare trace of the invocation, so
|
|
7
|
+
* errors, logs and spans get the trace id of the spans that Cloudflare exports.
|
|
8
|
+
*
|
|
9
|
+
* Only runs when Sentry tracing is not set up (no `tracesSampleRate` or `tracesSampler`), so a trace
|
|
10
|
+
* has one source: either the SDK or Cloudflare, never a mix of both.
|
|
11
|
+
*
|
|
12
|
+
* Does nothing when the current scope already continues a trace, for example an incoming Sentry
|
|
13
|
+
* trace, when Cloudflare does not trace the invocation, or when the runtime does not expose
|
|
14
|
+
* `Span.spanContext()`.
|
|
15
|
+
*/
|
|
16
|
+
function continueCloudflareTrace(context) {
|
|
17
|
+
if (hasSpansEnabled() || isContinuingTrace(getCurrentScope().getPropagationContext())) return;
|
|
18
|
+
let spanContext;
|
|
19
|
+
try {
|
|
20
|
+
const span = context?.tracing?.getActiveSpan?.();
|
|
21
|
+
spanContext = span?.isTraced ? span.spanContext?.() : void 0;
|
|
22
|
+
} catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!spanContext || !TRACE_ID_REGEXP.test(spanContext.traceId) || !SPAN_ID_REGEXP.test(spanContext.spanId)) return;
|
|
26
|
+
getCurrentScope().setPropagationContext({
|
|
27
|
+
traceId: spanContext.traceId,
|
|
28
|
+
parentSpanId: spanContext.spanId,
|
|
29
|
+
sampleRand: _INTERNAL_safeMathRandom()
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export { continueCloudflareTrace };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=cloudflareTrace.js.map
|