@sentry/server-utils 11.13.0 → 11.15.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/chunks/config.js +19 -5
- package/build/cjs/chunks/config.js.map +1 -1
- package/build/cjs/chunks/exports.js +593 -238
- package/build/cjs/chunks/exports.js.map +1 -1
- package/build/cjs/chunks/moduleInjectedTransform.js +6 -5
- package/build/cjs/chunks/moduleInjectedTransform.js.map +1 -1
- package/build/cjs/index.js +1186 -182
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/orchestrion/bundler/rollup.js +4 -4
- package/build/cjs/orchestrion/bundler/rollup.js.map +1 -1
- package/build/esm/ai/anthropic-ai/index.js +32 -56
- package/build/esm/ai/anthropic-ai/index.js.map +1 -1
- package/build/esm/ai/anthropic-ai/streaming.js +10 -6
- package/build/esm/ai/anthropic-ai/streaming.js.map +1 -1
- package/build/esm/ai/anthropic-ai/tool-runner.js +18 -3
- package/build/esm/ai/anthropic-ai/tool-runner.js.map +1 -1
- package/build/esm/ai/anthropic-ai/utils.js +41 -3
- package/build/esm/ai/anthropic-ai/utils.js.map +1 -1
- package/build/esm/ai/core/span-hooks.js +23 -0
- package/build/esm/ai/core/span-hooks.js.map +1 -0
- package/build/esm/ai/core/time-to-first-chunk.js +14 -0
- package/build/esm/ai/core/time-to-first-chunk.js.map +1 -0
- package/build/esm/ai/core/utils.js +29 -3
- package/build/esm/ai/core/utils.js.map +1 -1
- package/build/esm/ai/flue/index.js +15 -12
- package/build/esm/ai/flue/index.js.map +1 -1
- package/build/esm/ai/flue/utils.js +24 -17
- package/build/esm/ai/flue/utils.js.map +1 -1
- package/build/esm/ai/google-genai/constants.js +2 -1
- package/build/esm/ai/google-genai/constants.js.map +1 -1
- package/build/esm/ai/google-genai/decisions.js +25 -0
- package/build/esm/ai/google-genai/decisions.js.map +1 -0
- package/build/esm/ai/google-genai/index.js +35 -11
- package/build/esm/ai/google-genai/index.js.map +1 -1
- package/build/esm/ai/google-genai/streaming.js +6 -2
- package/build/esm/ai/google-genai/streaming.js.map +1 -1
- package/build/esm/ai/langchain/embeddings.js +5 -2
- package/build/esm/ai/langchain/embeddings.js.map +1 -1
- package/build/esm/ai/langchain/index.js +82 -24
- package/build/esm/ai/langchain/index.js.map +1 -1
- package/build/esm/ai/langchain/utils.js +9 -1
- package/build/esm/ai/langchain/utils.js.map +1 -1
- package/build/esm/ai/langgraph/agent-span.js +13 -5
- package/build/esm/ai/langgraph/agent-span.js.map +1 -1
- package/build/esm/ai/langgraph/index.js +13 -15
- package/build/esm/ai/langgraph/index.js.map +1 -1
- package/build/esm/ai/langgraph/stream.js +4 -3
- package/build/esm/ai/langgraph/stream.js.map +1 -1
- package/build/esm/ai/langgraph/utils.js +17 -8
- package/build/esm/ai/langgraph/utils.js.map +1 -1
- package/build/esm/ai/mastra/classifier-evaluation.js.map +1 -1
- package/build/esm/ai/mastra/index.js +33 -16
- package/build/esm/ai/mastra/index.js.map +1 -1
- package/build/esm/ai/mastra/utils.js +3 -5
- package/build/esm/ai/mastra/utils.js.map +1 -1
- package/build/esm/ai/mistral/index.js +28 -13
- package/build/esm/ai/mistral/index.js.map +1 -1
- package/build/esm/ai/mistral/streaming.js +6 -8
- package/build/esm/ai/mistral/streaming.js.map +1 -1
- package/build/esm/ai/mistral/utils.js +9 -1
- package/build/esm/ai/mistral/utils.js.map +1 -1
- package/build/esm/ai/openai/index.js +19 -8
- package/build/esm/ai/openai/index.js.map +1 -1
- package/build/esm/ai/openai/streaming.js +7 -2
- package/build/esm/ai/openai/streaming.js.map +1 -1
- package/build/esm/ai/pi-ai/chat.js +18 -1
- package/build/esm/ai/pi-ai/chat.js.map +1 -1
- package/build/esm/ai/pi-ai/recording.js +34 -15
- package/build/esm/ai/pi-ai/recording.js.map +1 -1
- package/build/esm/ai/pi-durable/index.js +7 -2
- package/build/esm/ai/pi-durable/index.js.map +1 -1
- package/build/esm/ai/pi-durable/runs.js.map +1 -1
- package/build/esm/ai/pi-durable/tools.js +18 -3
- package/build/esm/ai/pi-durable/tools.js.map +1 -1
- package/build/esm/ai/typesafe/index.js +14 -6
- package/build/esm/ai/typesafe/index.js.map +1 -1
- package/build/esm/ai/vercel-ai/index.js +3 -1
- package/build/esm/ai/vercel-ai/index.js.map +1 -1
- package/build/esm/ai/workers-ai/index.js +32 -14
- package/build/esm/ai/workers-ai/index.js.map +1 -1
- package/build/esm/ai/workers-ai/streaming.js +8 -10
- package/build/esm/ai/workers-ai/streaming.js.map +1 -1
- package/build/esm/cron/common.js +16 -0
- package/build/esm/cron/common.js.map +1 -0
- package/build/esm/cron/cron.js +82 -0
- package/build/esm/cron/cron.js.map +1 -0
- package/build/esm/cron/index.js +13 -0
- package/build/esm/cron/index.js.map +1 -0
- package/build/esm/cron/node-cron.js +66 -0
- package/build/esm/cron/node-cron.js.map +1 -0
- package/build/esm/cron/node-schedule.js +43 -0
- package/build/esm/cron/node-schedule.js.map +1 -0
- package/build/esm/index.js +6 -1
- package/build/esm/index.js.map +1 -1
- package/build/esm/integrations/anthropic.js +25 -16
- package/build/esm/integrations/anthropic.js.map +1 -1
- package/build/esm/integrations/aws-sdk/index.js +1 -0
- package/build/esm/integrations/aws-sdk/index.js.map +1 -1
- package/build/esm/integrations/aws-sdk/services/ServicesExtensions.js +3 -0
- package/build/esm/integrations/aws-sdk/services/ServicesExtensions.js.map +1 -1
- package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js +45 -12
- package/build/esm/integrations/aws-sdk/services/bedrock-runtime.js.map +1 -1
- package/build/esm/integrations/bullmq/contextManager.js +45 -0
- package/build/esm/integrations/bullmq/contextManager.js.map +1 -0
- package/build/esm/integrations/bullmq/index.js +44 -0
- package/build/esm/integrations/bullmq/index.js.map +1 -0
- package/build/esm/integrations/bullmq/meter.js +86 -0
- package/build/esm/integrations/bullmq/meter.js.map +1 -0
- package/build/esm/integrations/bullmq/span.js +114 -0
- package/build/esm/integrations/bullmq/span.js.map +1 -0
- package/build/esm/integrations/bullmq/tracer.js +62 -0
- package/build/esm/integrations/bullmq/tracer.js.map +1 -0
- package/build/esm/integrations/cron.js +2 -2
- package/build/esm/integrations/cron.js.map +1 -1
- package/build/esm/integrations/express/instrumentation.js +10 -1
- package/build/esm/integrations/express/instrumentation.js.map +1 -1
- package/build/esm/integrations/google-genai.js +26 -14
- package/build/esm/integrations/google-genai.js.map +1 -1
- package/build/esm/integrations/langgraph.js +5 -7
- package/build/esm/integrations/langgraph.js.map +1 -1
- package/build/esm/integrations/mastra-classifier.js +1 -1
- package/build/esm/integrations/mastra-classifier.js.map +1 -1
- package/build/esm/integrations/mistral.js +15 -5
- package/build/esm/integrations/mistral.js.map +1 -1
- package/build/esm/integrations/node-cron.js +5 -4
- package/build/esm/integrations/node-cron.js.map +1 -1
- package/build/esm/integrations/node-schedule.js +2 -2
- package/build/esm/integrations/node-schedule.js.map +1 -1
- package/build/esm/integrations/openai-compatible.js +16 -8
- package/build/esm/integrations/openai-compatible.js.map +1 -1
- package/build/esm/integrations/openai.js +16 -8
- package/build/esm/integrations/openai.js.map +1 -1
- package/build/esm/integrations/pi-ai.js +39 -18
- package/build/esm/integrations/pi-ai.js.map +1 -1
- package/build/esm/integrations/pino.js +131 -0
- package/build/esm/integrations/pino.js.map +1 -0
- package/build/esm/integrations/typesafe.js +17 -3
- package/build/esm/integrations/typesafe.js.map +1 -1
- package/build/esm/integrations/vercel-ai/index.js.map +1 -1
- package/build/esm/integrations/vercel-ai/util.js +3 -2
- package/build/esm/integrations/vercel-ai/util.js.map +1 -1
- package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js +53 -18
- package/build/esm/integrations/vercel-ai/vercel-ai-dc-subscriber.js.map +1 -1
- package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js +22 -16
- package/build/esm/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.js.map +1 -1
- package/build/esm/integrations/winston.js +90 -0
- package/build/esm/integrations/winston.js.map +1 -0
- package/build/esm/orchestrion/bundler/moduleInjectedTransform.js +6 -5
- package/build/esm/orchestrion/bundler/moduleInjectedTransform.js.map +1 -1
- package/build/esm/orchestrion/bundler/rollup.js +4 -4
- package/build/esm/orchestrion/bundler/rollup.js.map +1 -1
- package/build/esm/orchestrion/config/google-genai.js +19 -5
- package/build/esm/orchestrion/config/google-genai.js.map +1 -1
- package/build/esm/orchestrion/detect.js +1 -1
- package/build/esm/orchestrion/detect.js.map +1 -1
- package/build/esm/package.json +1 -1
- package/build/esm/utils/cronMonitoring.js +128 -50
- package/build/esm/utils/cronMonitoring.js.map +1 -1
- package/build/types/ai/anthropic-ai/index.d.ts +1 -5
- package/build/types/ai/anthropic-ai/index.d.ts.map +1 -1
- package/build/types/ai/anthropic-ai/streaming.d.ts +3 -2
- package/build/types/ai/anthropic-ai/streaming.d.ts.map +1 -1
- package/build/types/ai/anthropic-ai/tool-runner.d.ts.map +1 -1
- package/build/types/ai/anthropic-ai/types.d.ts +24 -3
- package/build/types/ai/anthropic-ai/types.d.ts.map +1 -1
- package/build/types/ai/anthropic-ai/utils.d.ts +2 -3
- package/build/types/ai/anthropic-ai/utils.d.ts.map +1 -1
- package/build/types/ai/core/span-hooks.d.ts +31 -0
- package/build/types/ai/core/span-hooks.d.ts.map +1 -0
- package/build/types/ai/core/time-to-first-chunk.d.ts +7 -0
- package/build/types/ai/core/time-to-first-chunk.d.ts.map +1 -0
- package/build/types/ai/core/utils.d.ts +30 -1
- package/build/types/ai/core/utils.d.ts.map +1 -1
- package/build/types/ai/flue/index.d.ts +13 -5
- package/build/types/ai/flue/index.d.ts.map +1 -1
- package/build/types/ai/flue/types.d.ts +20 -2
- package/build/types/ai/flue/types.d.ts.map +1 -1
- package/build/types/ai/flue/utils.d.ts +5 -9
- package/build/types/ai/flue/utils.d.ts.map +1 -1
- package/build/types/ai/google-genai/constants.d.ts +3 -0
- package/build/types/ai/google-genai/constants.d.ts.map +1 -1
- package/build/types/ai/google-genai/decisions.d.ts +8 -0
- package/build/types/ai/google-genai/decisions.d.ts.map +1 -0
- package/build/types/ai/google-genai/index.d.ts +3 -1
- package/build/types/ai/google-genai/index.d.ts.map +1 -1
- package/build/types/ai/google-genai/streaming.d.ts +2 -1
- package/build/types/ai/google-genai/streaming.d.ts.map +1 -1
- package/build/types/ai/google-genai/types.d.ts +17 -3
- package/build/types/ai/google-genai/types.d.ts.map +1 -1
- package/build/types/ai/langchain/index.d.ts.map +1 -1
- package/build/types/ai/langchain/types.d.ts +49 -3
- package/build/types/ai/langchain/types.d.ts.map +1 -1
- package/build/types/ai/langchain/utils.d.ts +6 -0
- package/build/types/ai/langchain/utils.d.ts.map +1 -1
- package/build/types/ai/langgraph/agent-span.d.ts +4 -1
- package/build/types/ai/langgraph/agent-span.d.ts.map +1 -1
- package/build/types/ai/langgraph/index.d.ts +1 -1
- package/build/types/ai/langgraph/index.d.ts.map +1 -1
- package/build/types/ai/langgraph/stream.d.ts.map +1 -1
- package/build/types/ai/langgraph/types.d.ts +14 -3
- package/build/types/ai/langgraph/types.d.ts.map +1 -1
- package/build/types/ai/langgraph/utils.d.ts +3 -0
- package/build/types/ai/langgraph/utils.d.ts.map +1 -1
- package/build/types/ai/mastra/classifier-evaluation.d.ts +3 -3
- package/build/types/ai/mastra/classifier-evaluation.d.ts.map +1 -1
- package/build/types/ai/mastra/index.d.ts +17 -3
- package/build/types/ai/mastra/index.d.ts.map +1 -1
- package/build/types/ai/mastra/types.d.ts +2 -0
- package/build/types/ai/mastra/types.d.ts.map +1 -1
- package/build/types/ai/mastra/utils.d.ts.map +1 -1
- package/build/types/ai/mistral/index.d.ts.map +1 -1
- package/build/types/ai/mistral/streaming.d.ts +2 -1
- package/build/types/ai/mistral/streaming.d.ts.map +1 -1
- package/build/types/ai/mistral/types.d.ts +14 -3
- package/build/types/ai/mistral/types.d.ts.map +1 -1
- package/build/types/ai/mistral/utils.d.ts +5 -0
- package/build/types/ai/mistral/utils.d.ts.map +1 -1
- package/build/types/ai/openai/index.d.ts.map +1 -1
- package/build/types/ai/openai/streaming.d.ts +3 -1
- package/build/types/ai/openai/streaming.d.ts.map +1 -1
- package/build/types/ai/openai/types.d.ts +14 -3
- package/build/types/ai/openai/types.d.ts.map +1 -1
- package/build/types/ai/pi-ai/chat.d.ts +7 -1
- package/build/types/ai/pi-ai/chat.d.ts.map +1 -1
- package/build/types/ai/pi-ai/recording.d.ts +21 -9
- package/build/types/ai/pi-ai/recording.d.ts.map +1 -1
- package/build/types/ai/pi-ai/types.d.ts +16 -0
- package/build/types/ai/pi-ai/types.d.ts.map +1 -1
- package/build/types/ai/pi-durable/index.d.ts +12 -3
- package/build/types/ai/pi-durable/index.d.ts.map +1 -1
- package/build/types/ai/pi-durable/runs.d.ts +2 -0
- package/build/types/ai/pi-durable/runs.d.ts.map +1 -1
- package/build/types/ai/pi-durable/tools.d.ts +4 -3
- package/build/types/ai/pi-durable/tools.d.ts.map +1 -1
- package/build/types/ai/pi-durable/types.d.ts +15 -0
- package/build/types/ai/pi-durable/types.d.ts.map +1 -1
- package/build/types/ai/typesafe/index.d.ts +10 -2
- package/build/types/ai/typesafe/index.d.ts.map +1 -1
- package/build/types/ai/vercel-ai/index.d.ts.map +1 -1
- package/build/types/ai/vercel-ai/vercel-ai-attributes.d.ts +3 -0
- package/build/types/ai/vercel-ai/vercel-ai-attributes.d.ts.map +1 -1
- package/build/types/ai/workers-ai/index.d.ts.map +1 -1
- package/build/types/ai/workers-ai/streaming.d.ts +2 -1
- package/build/types/ai/workers-ai/streaming.d.ts.map +1 -1
- package/build/types/ai/workers-ai/types.d.ts +18 -3
- package/build/types/ai/workers-ai/types.d.ts.map +1 -1
- package/build/types/cron/common.d.ts +8 -0
- package/build/types/cron/common.d.ts.map +1 -0
- package/build/types/cron/cron.d.ts +45 -0
- package/build/types/cron/cron.d.ts.map +1 -0
- package/build/types/cron/index.d.ts +10 -0
- package/build/types/cron/index.d.ts.map +1 -0
- package/build/types/cron/node-cron.d.ts +33 -0
- package/build/types/cron/node-cron.d.ts.map +1 -0
- package/build/types/cron/node-schedule.d.ts +19 -0
- package/build/types/cron/node-schedule.d.ts.map +1 -0
- package/build/types/index.d.ts +5 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/integrations/anthropic.d.ts +2 -1
- package/build/types/integrations/anthropic.d.ts.map +1 -1
- package/build/types/integrations/aws-sdk/index.d.ts +3 -3
- package/build/types/integrations/aws-sdk/index.d.ts.map +1 -1
- package/build/types/integrations/aws-sdk/services/ServiceExtension.d.ts +1 -0
- package/build/types/integrations/aws-sdk/services/ServiceExtension.d.ts.map +1 -1
- package/build/types/integrations/aws-sdk/services/ServicesExtensions.d.ts +3 -2
- package/build/types/integrations/aws-sdk/services/ServicesExtensions.d.ts.map +1 -1
- package/build/types/integrations/aws-sdk/services/bedrock-runtime.d.ts +25 -4
- package/build/types/integrations/aws-sdk/services/bedrock-runtime.d.ts.map +1 -1
- package/build/types/integrations/bullmq/contextManager.d.ts +13 -0
- package/build/types/integrations/bullmq/contextManager.d.ts.map +1 -0
- package/build/types/integrations/bullmq/index.d.ts +43 -0
- package/build/types/integrations/bullmq/index.d.ts.map +1 -0
- package/build/types/integrations/bullmq/meter.d.ts +7 -0
- package/build/types/integrations/bullmq/meter.d.ts.map +1 -0
- package/build/types/integrations/bullmq/span.d.ts +35 -0
- package/build/types/integrations/bullmq/span.d.ts.map +1 -0
- package/build/types/integrations/bullmq/tracer.d.ts +5 -0
- package/build/types/integrations/bullmq/tracer.d.ts.map +1 -0
- package/build/types/integrations/bullmq/types.d.ts +72 -0
- package/build/types/integrations/bullmq/types.d.ts.map +1 -0
- package/build/types/integrations/cron.d.ts.map +1 -1
- package/build/types/integrations/express/types.d.ts +1 -0
- package/build/types/integrations/express/types.d.ts.map +1 -1
- package/build/types/integrations/flue.d.ts +2 -1
- package/build/types/integrations/flue.d.ts.map +1 -1
- package/build/types/integrations/google-genai.d.ts +5 -4
- package/build/types/integrations/google-genai.d.ts.map +1 -1
- package/build/types/integrations/groq.d.ts +1 -1
- package/build/types/integrations/langchain.d.ts +2 -1
- package/build/types/integrations/langchain.d.ts.map +1 -1
- package/build/types/integrations/langgraph.d.ts +2 -1
- package/build/types/integrations/langgraph.d.ts.map +1 -1
- package/build/types/integrations/mistral.d.ts +2 -1
- package/build/types/integrations/mistral.d.ts.map +1 -1
- package/build/types/integrations/node-cron.d.ts +1 -1
- package/build/types/integrations/node-cron.d.ts.map +1 -1
- package/build/types/integrations/node-schedule.d.ts.map +1 -1
- package/build/types/integrations/openai-compatible.d.ts.map +1 -1
- package/build/types/integrations/openai.d.ts +2 -1
- package/build/types/integrations/openai.d.ts.map +1 -1
- package/build/types/integrations/pi-ai.d.ts +6 -3
- package/build/types/integrations/pi-ai.d.ts.map +1 -1
- package/build/types/integrations/pi-durable.d.ts +2 -1
- package/build/types/integrations/pi-durable.d.ts.map +1 -1
- package/build/types/integrations/pino.d.ts +61 -0
- package/build/types/integrations/pino.d.ts.map +1 -0
- package/build/types/integrations/together-ai.d.ts +1 -1
- package/build/types/integrations/typesafe.d.ts +2 -2
- package/build/types/integrations/typesafe.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/index.d.ts +3 -3
- package/build/types/integrations/vercel-ai/index.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/util.d.ts +2 -1
- package/build/types/integrations/vercel-ai/util.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts +20 -4
- package/build/types/integrations/vercel-ai/vercel-ai-dc-subscriber.d.ts.map +1 -1
- package/build/types/integrations/vercel-ai/vercel-ai-orchestrion-subscriber.d.ts.map +1 -1
- package/build/types/integrations/winston.d.ts +55 -0
- package/build/types/integrations/winston.d.ts.map +1 -0
- package/build/types/orchestrion/bundler/moduleInjectedTransform.d.ts.map +1 -1
- package/build/types/orchestrion/bundler/rollup.d.ts +3 -3
- package/build/types/orchestrion/bundler/rollup.d.ts.map +1 -1
- package/build/types/orchestrion/channels.d.ts +1 -0
- package/build/types/orchestrion/channels.d.ts.map +1 -1
- package/build/types/orchestrion/config/google-genai.d.ts +13 -0
- package/build/types/orchestrion/config/google-genai.d.ts.map +1 -1
- package/build/types/utils/cronMonitoring.d.ts +4 -5
- package/build/types/utils/cronMonitoring.d.ts.map +1 -1
- package/package.json +3 -3
package/build/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ let _sentry_conventions_op = require("@sentry/conventions/op");
|
|
|
10
10
|
let _sentry_core_server = require("@sentry/core/server");
|
|
11
11
|
let node_diagnostics_channel = require("node:diagnostics_channel");
|
|
12
12
|
node_diagnostics_channel = require_rolldown_runtime.__toESM(node_diagnostics_channel);
|
|
13
|
+
let _sentry_conventions_metrics = require("@sentry/conventions/metrics");
|
|
13
14
|
let node_module = require("node:module");
|
|
14
15
|
let node_path = require("node:path");
|
|
15
16
|
let node_url = require("node:url");
|
|
@@ -1190,11 +1191,11 @@ var ActiveTracingHelper = class {
|
|
|
1190
1191
|
if (options.active === false) {
|
|
1191
1192
|
const span = (0, _sentry_core.startInactiveSpan)(spanOptions);
|
|
1192
1193
|
registerPrismaSpan(span.spanContext().spanId, span);
|
|
1193
|
-
return endSpan$
|
|
1194
|
+
return endSpan$2(span, () => callback(span, parentSpan));
|
|
1194
1195
|
}
|
|
1195
1196
|
return (0, _sentry_core.startSpanManual)(spanOptions, (span) => {
|
|
1196
1197
|
registerPrismaSpan(span.spanContext().spanId, span);
|
|
1197
|
-
return endSpan$
|
|
1198
|
+
return endSpan$2(span, () => callback(span, parentSpan));
|
|
1198
1199
|
});
|
|
1199
1200
|
}
|
|
1200
1201
|
};
|
|
@@ -1224,7 +1225,7 @@ function dispatchEngineSpan(engineSpan, allSpans, linkIds, ignoreSpanTypes) {
|
|
|
1224
1225
|
span.end(engineSpan.endTime);
|
|
1225
1226
|
});
|
|
1226
1227
|
}
|
|
1227
|
-
function endSpan$
|
|
1228
|
+
function endSpan$2(span, run) {
|
|
1228
1229
|
let result;
|
|
1229
1230
|
try {
|
|
1230
1231
|
result = run();
|
|
@@ -1917,12 +1918,13 @@ function instrumentAnthropic(options) {
|
|
|
1917
1918
|
for (const { channel, operation, stream } of INSTRUMENTED_CHANNELS$3) bindTracingChannelToSpan(tracingChannel(channel), (data) => createGenAiSpan$4(data, operation, options, stream), {
|
|
1918
1919
|
beforeSpanEnd: (span, data) => {
|
|
1919
1920
|
if ("error" in data) require_exports.markCancelledIfAborted(span, require_exports.getRequestSignal(data.arguments?.[1]));
|
|
1920
|
-
require_exports.addResponseAttributes$3(span, data.result,
|
|
1921
|
+
require_exports.addResponseAttributes$3(span, data.result, !!data._sentryRecordOutputs);
|
|
1922
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
1921
1923
|
},
|
|
1922
|
-
deferSpanEnd: ({ span, data, end }) => wrapThreadStreamRequest(span, data, end
|
|
1924
|
+
deferSpanEnd: ({ span, data, end }) => wrapThreadStreamRequest(span, data, end) || wrapApiPromiseResponse(data.result, (response) => {
|
|
1923
1925
|
data.result = response;
|
|
1924
|
-
if (!wrapStreamResult$3(span, data, stream
|
|
1925
|
-
}, end) || wrapStreamResult$3(span, data, stream
|
|
1926
|
+
if (!wrapStreamResult$3(span, data, stream)) end();
|
|
1927
|
+
}, end) || wrapStreamResult$3(span, data, stream)
|
|
1926
1928
|
});
|
|
1927
1929
|
tracingChannel(CHANNELS.ANTHROPIC_TOOL_RUNNER).end.subscribe((message) => {
|
|
1928
1930
|
require_exports.instrumentToolRunner(message.result, options);
|
|
@@ -1949,7 +1951,12 @@ function createGenAiSpan$4(data, operation, options, stream) {
|
|
|
1949
1951
|
const requestOptions = args[1];
|
|
1950
1952
|
if (isStreamHelperRequest(requestOptions?.headers) && isInsideStreamHelperSpan()) return;
|
|
1951
1953
|
const params = typeof args[0] === "object" && args[0] !== null ? args[0] : void 0;
|
|
1952
|
-
const
|
|
1954
|
+
const call = {
|
|
1955
|
+
operation,
|
|
1956
|
+
request: params
|
|
1957
|
+
};
|
|
1958
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, call);
|
|
1959
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
1953
1960
|
const attributes = require_exports.extractRequestAttributes$2(args, operation, recordInputs, require_exports.getProviderName(data.self));
|
|
1954
1961
|
const model = attributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] || "unknown";
|
|
1955
1962
|
attributes[_sentry_conventions_attributes.SENTRY_ORIGIN] = require_exports.ANTHROPIC_AI_ORIGIN;
|
|
@@ -1960,6 +1967,8 @@ function createGenAiSpan$4(data, operation, options, stream) {
|
|
|
1960
1967
|
attributes
|
|
1961
1968
|
});
|
|
1962
1969
|
if (recordInputs && params) require_exports.addPrivateRequestAttributes$1(span, params);
|
|
1970
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
1971
|
+
data._sentryOnSpanEnd = (result) => require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
1963
1972
|
if (stream === "message-stream") streamHelperSpans.add(span);
|
|
1964
1973
|
return span;
|
|
1965
1974
|
}
|
|
@@ -2001,18 +2010,18 @@ const threadStreams = /* @__PURE__ */ new WeakMap();
|
|
|
2001
2010
|
* End the span of a thread stream's `create()` call from the stream once the response arrives. A thread may
|
|
2002
2011
|
* retry a rejected call, so a failed call ends its own span and only the one that succeeds reads the stream.
|
|
2003
2012
|
*/
|
|
2004
|
-
function wrapThreadStreamRequest(span, data, end
|
|
2013
|
+
function wrapThreadStreamRequest(span, data, end) {
|
|
2005
2014
|
const signal = (data.arguments?.[1])?.signal;
|
|
2006
2015
|
const threadStream = signal && threadStreams.get(signal);
|
|
2007
2016
|
const request = data.result;
|
|
2008
2017
|
if (!threadStream || threadStream.stream.ended || typeof request?._responseProps !== "function") return false;
|
|
2009
2018
|
const { stream, callerSignal } = threadStream;
|
|
2010
|
-
const
|
|
2019
|
+
const recordOutputs = !!data._sentryRecordOutputs;
|
|
2011
2020
|
request._responseProps().then(() => {
|
|
2012
2021
|
threadStreams.delete(signal);
|
|
2013
|
-
require_exports.instrumentMessageStream(stream, span, recordOutputs, callerSignal);
|
|
2022
|
+
require_exports.instrumentMessageStream(stream, span, recordOutputs, callerSignal, data._sentryOnSpanEnd);
|
|
2014
2023
|
}, (error) => {
|
|
2015
|
-
if (signal.aborted) require_exports.instrumentMessageStream(stream, span, recordOutputs, callerSignal);
|
|
2024
|
+
if (signal.aborted) require_exports.instrumentMessageStream(stream, span, recordOutputs, callerSignal, data._sentryOnSpanEnd);
|
|
2016
2025
|
else end(error);
|
|
2017
2026
|
});
|
|
2018
2027
|
return true;
|
|
@@ -2025,17 +2034,17 @@ function wrapThreadStreamRequest(span, data, end, options) {
|
|
|
2025
2034
|
* the span when iteration finishes.
|
|
2026
2035
|
* - `message-stream`: `instrumentMessageStream` attaches `'message'`/`'error'`/`'end'` listeners that end the span.
|
|
2027
2036
|
*/
|
|
2028
|
-
function wrapStreamResult$3(span, data, stream
|
|
2029
|
-
const
|
|
2037
|
+
function wrapStreamResult$3(span, data, stream) {
|
|
2038
|
+
const recordOutputs = !!data._sentryRecordOutputs;
|
|
2030
2039
|
const result = data.result;
|
|
2031
2040
|
if (stream === "async-iterable" && isAsyncIterable$3(result)) {
|
|
2032
2041
|
const iterate = result[Symbol.asyncIterator].bind(result);
|
|
2033
|
-
const instrumented = require_exports.instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs);
|
|
2042
|
+
const instrumented = require_exports.instrumentAsyncIterableStream({ [Symbol.asyncIterator]: iterate }, span, recordOutputs, data._sentryOnSpanEnd);
|
|
2034
2043
|
result[Symbol.asyncIterator] = () => instrumented;
|
|
2035
2044
|
return true;
|
|
2036
2045
|
}
|
|
2037
2046
|
if (stream === "message-stream" && isMessageStream(result)) {
|
|
2038
|
-
require_exports.instrumentMessageStream(result, span, recordOutputs, require_exports.getRequestSignal(data.arguments?.[1]));
|
|
2047
|
+
require_exports.instrumentMessageStream(result, span, recordOutputs, require_exports.getRequestSignal(data.arguments?.[1]), data._sentryOnSpanEnd);
|
|
2039
2048
|
return true;
|
|
2040
2049
|
}
|
|
2041
2050
|
return false;
|
|
@@ -2205,9 +2214,33 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2205
2214
|
constructor(_options = {}) {
|
|
2206
2215
|
this._options = _options;
|
|
2207
2216
|
this._piAiRequests = /* @__PURE__ */ new WeakSet();
|
|
2217
|
+
this._calls = /* @__PURE__ */ new WeakMap();
|
|
2218
|
+
}
|
|
2219
|
+
_resolveRecording(request) {
|
|
2220
|
+
const info = {
|
|
2221
|
+
commandName: request.commandName,
|
|
2222
|
+
input: request.commandInput
|
|
2223
|
+
};
|
|
2224
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(this._options, info);
|
|
2225
|
+
this._calls.set(request, {
|
|
2226
|
+
info,
|
|
2227
|
+
recordOutputs
|
|
2228
|
+
});
|
|
2229
|
+
return recordInputs;
|
|
2208
2230
|
}
|
|
2209
|
-
|
|
2210
|
-
return
|
|
2231
|
+
_shouldRecordOutputs(response) {
|
|
2232
|
+
return this._calls.get(response.request)?.recordOutputs ?? false;
|
|
2233
|
+
}
|
|
2234
|
+
_runSpanEnd(request, span, result) {
|
|
2235
|
+
const call = this._calls.get(request);
|
|
2236
|
+
if (call) require_exports.runGenAiSpanEnd(this._options, span, call.info, result);
|
|
2237
|
+
}
|
|
2238
|
+
requestPostSpanHook(request, span) {
|
|
2239
|
+
const call = this._calls.get(request);
|
|
2240
|
+
if (call) require_exports.runGenAiSpanStart(this._options, span, call.info);
|
|
2241
|
+
}
|
|
2242
|
+
errorHook(request, error, span) {
|
|
2243
|
+
this._runSpanEnd(request, span, { error });
|
|
2211
2244
|
}
|
|
2212
2245
|
requestPreSpanHook(request) {
|
|
2213
2246
|
if (require_exports.isInsidePiAiSpan()) {
|
|
@@ -2242,6 +2275,7 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2242
2275
|
[_sentry_conventions_attributes.GEN_AI_PROVIDER_NAME]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,
|
|
2243
2276
|
[_sentry_conventions_attributes.GEN_AI_OPERATION_NAME]: GEN_AI_OPERATION_NAME_VALUE_CHAT
|
|
2244
2277
|
};
|
|
2278
|
+
const recordInputs = this._resolveRecording(request);
|
|
2245
2279
|
const modelId = request.commandInput.modelId;
|
|
2246
2280
|
if (modelId) {
|
|
2247
2281
|
spanAttributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] = modelId;
|
|
@@ -2255,7 +2289,7 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2255
2289
|
if (topP !== void 0) spanAttributes[_sentry_conventions_attributes.GEN_AI_REQUEST_TOP_P] = topP;
|
|
2256
2290
|
if (stopSequences !== void 0) spanAttributes[_sentry_conventions_attributes.GEN_AI_REQUEST_STOP_SEQUENCES] = stopSequences;
|
|
2257
2291
|
}
|
|
2258
|
-
if (
|
|
2292
|
+
if (recordInputs) Object.assign(spanAttributes, getConverseInputAttributes(request.commandInput));
|
|
2259
2293
|
return {
|
|
2260
2294
|
spanName,
|
|
2261
2295
|
spanOp: _sentry_conventions_op.GEN_AI_CHAT,
|
|
@@ -2269,6 +2303,7 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2269
2303
|
[_sentry_conventions_attributes.GEN_AI_PROVIDER_NAME]: GEN_AI_SYSTEM_VALUE_AWS_BEDROCK,
|
|
2270
2304
|
[_sentry_conventions_attributes.GEN_AI_OPERATION_NAME]: GEN_AI_OPERATION_NAME_VALUE_GENERATE_CONTENT
|
|
2271
2305
|
};
|
|
2306
|
+
const recordInputs = this._resolveRecording(request);
|
|
2272
2307
|
const modelId = request.commandInput?.modelId;
|
|
2273
2308
|
if (modelId) {
|
|
2274
2309
|
spanAttributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] = modelId;
|
|
@@ -2314,7 +2349,7 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2314
2349
|
if (requestBody.top_p !== void 0) spanAttributes[_sentry_conventions_attributes.GEN_AI_REQUEST_TOP_P] = requestBody.top_p;
|
|
2315
2350
|
if (requestBody.stop !== void 0) spanAttributes[_sentry_conventions_attributes.GEN_AI_REQUEST_STOP_SEQUENCES] = requestBody.stop;
|
|
2316
2351
|
}
|
|
2317
|
-
if (
|
|
2352
|
+
if (recordInputs) Object.assign(spanAttributes, getInvokeModelInputAttributes(modelId, requestBody));
|
|
2318
2353
|
}
|
|
2319
2354
|
return {
|
|
2320
2355
|
spanName,
|
|
@@ -2326,15 +2361,17 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2326
2361
|
_responseHookConverse(response, span) {
|
|
2327
2362
|
const { stopReason, usage, output } = response.data;
|
|
2328
2363
|
setStopReason(span, stopReason);
|
|
2329
|
-
if (this.
|
|
2364
|
+
if (this._shouldRecordOutputs(response)) setOutputMessages(span, contentBlocksToParts(output?.message?.content));
|
|
2330
2365
|
span.setAttributes(require_exports.getTokenUsageAttributes(typeof usage?.inputTokens === "number" ? usage.inputTokens + (usage.cacheReadInputTokens ?? 0) + (usage.cacheWriteInputTokens ?? 0) : void 0, usage?.outputTokens, usage?.cacheWriteInputTokens, usage?.cacheReadInputTokens));
|
|
2366
|
+
this._runSpanEnd(response.request, span, { response: response.data });
|
|
2331
2367
|
}
|
|
2332
2368
|
_responseHookConverseStream(response, span) {
|
|
2333
2369
|
if (!response.data?.stream) {
|
|
2370
|
+
this._runSpanEnd(response.request, span, { response: response.data });
|
|
2334
2371
|
span.end();
|
|
2335
2372
|
return;
|
|
2336
2373
|
}
|
|
2337
|
-
response.data.stream = instrumentStream(response.data.stream, span, response.request.abortSignal, this.
|
|
2374
|
+
response.data.stream = instrumentStream(response.data.stream, span, response.request.abortSignal, this._shouldRecordOutputs(response), processConverseStreamEvent, (result) => this._runSpanEnd(response.request, span, result));
|
|
2338
2375
|
}
|
|
2339
2376
|
_responseHookInvokeModel(response, span) {
|
|
2340
2377
|
const currentModelId = response.request.commandInput?.modelId;
|
|
@@ -2363,18 +2400,20 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2363
2400
|
} else if (currentModelId.includes("mistral")) {
|
|
2364
2401
|
if (responseBody.outputs?.[0]?.text !== void 0) span.setAttribute(_sentry_conventions_attributes.GEN_AI_USAGE_OUTPUT_TOKENS, Math.ceil(responseBody.outputs[0].text.length / 6));
|
|
2365
2402
|
}
|
|
2366
|
-
if (this.
|
|
2403
|
+
if (this._shouldRecordOutputs(response)) setOutputMessages(span, getInvokeModelOutputParts(responseBody));
|
|
2367
2404
|
}
|
|
2405
|
+
this._runSpanEnd(response.request, span, { response: response.data });
|
|
2368
2406
|
}
|
|
2369
2407
|
_responseHookInvokeModelWithResponseStream(response, span) {
|
|
2370
2408
|
const stream = response.data?.body;
|
|
2371
2409
|
const modelId = response.request.commandInput?.modelId;
|
|
2372
2410
|
if (!stream) {
|
|
2411
|
+
this._runSpanEnd(response.request, span, { response: response.data });
|
|
2373
2412
|
span.end();
|
|
2374
2413
|
return;
|
|
2375
2414
|
}
|
|
2376
2415
|
const processChunk = typeof modelId === "string" ? resolveStreamProcessor(modelId) : void 0;
|
|
2377
|
-
response.data.body = instrumentStream(stream, span, response.request.abortSignal, this.
|
|
2416
|
+
response.data.body = instrumentStream(stream, span, response.request.abortSignal, this._shouldRecordOutputs(response), (item, state) => {
|
|
2378
2417
|
if (processChunk) {
|
|
2379
2418
|
const parsedChunk = parseChunk(item?.chunk?.bytes);
|
|
2380
2419
|
if (parsedChunk) {
|
|
@@ -2382,7 +2421,7 @@ var BedrockRuntimeServiceExtension = class {
|
|
|
2382
2421
|
processChunk(parsedChunk, state);
|
|
2383
2422
|
}
|
|
2384
2423
|
}
|
|
2385
|
-
});
|
|
2424
|
+
}, (result) => this._runSpanEnd(response.request, span, result));
|
|
2386
2425
|
}
|
|
2387
2426
|
};
|
|
2388
2427
|
function getInvokeModelOutputParts(responseBody) {
|
|
@@ -2407,13 +2446,14 @@ function resolveStreamProcessor(modelId) {
|
|
|
2407
2446
|
if (modelId.includes("mistral")) return processMistralChunk;
|
|
2408
2447
|
}
|
|
2409
2448
|
/** Collects the stream items into a state and sets the span attributes from it when the stream ends. */
|
|
2410
|
-
async function* instrumentStream(stream, span, abortSignal, recordOutputs, processItem) {
|
|
2449
|
+
async function* instrumentStream(stream, span, abortSignal, recordOutputs, processItem, beforeSpanEnd) {
|
|
2411
2450
|
const state = {
|
|
2412
2451
|
finishReasons: [],
|
|
2413
2452
|
responseTexts: [],
|
|
2414
2453
|
toolCalls: [],
|
|
2415
2454
|
parts: recordOutputs ? [] : void 0
|
|
2416
2455
|
};
|
|
2456
|
+
const result = {};
|
|
2417
2457
|
try {
|
|
2418
2458
|
for await (const item of stream) {
|
|
2419
2459
|
processItem(item, state);
|
|
@@ -2421,10 +2461,11 @@ async function* instrumentStream(stream, span, abortSignal, recordOutputs, proce
|
|
|
2421
2461
|
}
|
|
2422
2462
|
} catch (error) {
|
|
2423
2463
|
span.setStatus(require_exports.getErrorStatus(abortSignal));
|
|
2464
|
+
result.error = error;
|
|
2424
2465
|
throw error;
|
|
2425
2466
|
} finally {
|
|
2426
2467
|
if (state.parts) setOutputMessages(span, state.parts);
|
|
2427
|
-
require_exports.endStreamSpan(span, state, false);
|
|
2468
|
+
require_exports.endStreamSpan(span, state, false, () => beforeSpanEnd(result));
|
|
2428
2469
|
}
|
|
2429
2470
|
}
|
|
2430
2471
|
function processConverseStreamEvent(event, state) {
|
|
@@ -2912,6 +2953,9 @@ var ServicesExtensions = class {
|
|
|
2912
2953
|
responseHook(response, span) {
|
|
2913
2954
|
this._services.get(response.request.serviceName)?.responseHook?.(response, span);
|
|
2914
2955
|
}
|
|
2956
|
+
errorHook(request, error, span) {
|
|
2957
|
+
this._services.get(request.serviceName)?.errorHook?.(request, error, span);
|
|
2958
|
+
}
|
|
2915
2959
|
};
|
|
2916
2960
|
// src/integrations/aws-sdk/utils.ts
|
|
2917
2961
|
function removeSuffixFromStringIfExists(str, suffixToRemove) {
|
|
@@ -3012,6 +3056,7 @@ function instrumentAwsSdk(servicesExtensions) {
|
|
|
3012
3056
|
httpStatusCode: errMetadata?.httpStatusCode,
|
|
3013
3057
|
extendedRequestId: err?.extendedRequestId ?? errMetadata?.extendedRequestId
|
|
3014
3058
|
});
|
|
3059
|
+
servicesExtensions.errorHook(normalizedRequest, data.error, span);
|
|
3015
3060
|
return;
|
|
3016
3061
|
}
|
|
3017
3062
|
const output = data.result;
|
|
@@ -3188,7 +3233,7 @@ function instrumentGenericPool() {
|
|
|
3188
3233
|
}));
|
|
3189
3234
|
}
|
|
3190
3235
|
// src/utils/cronMonitoring.ts
|
|
3191
|
-
const MONITORED = Symbol.for("sentry.cron.monitored");
|
|
3236
|
+
const MONITORED$1 = Symbol.for("sentry.cron.monitored");
|
|
3192
3237
|
/**
|
|
3193
3238
|
* Calls `onJob` with the arguments of each call on a scheduler's job-creation channel, so it can wrap the job.
|
|
3194
3239
|
* Errors are logged and the job is created unmonitored.
|
|
@@ -3220,63 +3265,73 @@ function subscribeToScheduleChange(channelName, integrationName, onChange, onSta
|
|
|
3220
3265
|
}
|
|
3221
3266
|
/** Whether a job is named, not excluded, and not already monitored by `Sentry.cron.instrument*` or `wrapScheduledJob`. */
|
|
3222
3267
|
function shouldMonitorJob(name, job, excludeJobs) {
|
|
3223
|
-
return typeof name === "string" && !!name && typeof job === "function" && !job[MONITORED] && !(0, _sentry_core.stringMatchesSomePattern)(name, excludeJobs, true);
|
|
3268
|
+
return typeof name === "string" && !!name && typeof job === "function" && !job[MONITORED$1] && !(0, _sentry_core.stringMatchesSomePattern)(name, excludeJobs, true);
|
|
3224
3269
|
}
|
|
3225
|
-
const
|
|
3270
|
+
const COMMON_NICKNAMES = {
|
|
3226
3271
|
"@yearly": "0 0 1 1 *",
|
|
3227
|
-
"@annually": "0 0 1 1 *",
|
|
3228
3272
|
"@monthly": "0 0 1 * *",
|
|
3229
3273
|
"@weekly": "0 0 * * 0",
|
|
3230
3274
|
"@daily": "0 0 * * *",
|
|
3231
|
-
"@
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
"
|
|
3235
|
-
|
|
3275
|
+
"@hourly": "0 * * * *"
|
|
3276
|
+
};
|
|
3277
|
+
const NICKNAMES = {
|
|
3278
|
+
"node-cron": {
|
|
3279
|
+
...COMMON_NICKNAMES,
|
|
3280
|
+
"@annually": "0 0 1 1 *",
|
|
3281
|
+
"@midnight": "0 0 * * *"
|
|
3282
|
+
},
|
|
3283
|
+
cron: {
|
|
3284
|
+
...COMMON_NICKNAMES,
|
|
3285
|
+
"@minutely": "* * * * *",
|
|
3286
|
+
"@weekdays": "0 0 * * 1-5",
|
|
3287
|
+
"@weekends": "0 0 * * 0,6"
|
|
3288
|
+
},
|
|
3289
|
+
"cron-parser": COMMON_NICKNAMES
|
|
3236
3290
|
};
|
|
3237
3291
|
const MONTHS = [
|
|
3238
|
-
"
|
|
3239
|
-
"
|
|
3240
|
-
"
|
|
3241
|
-
"
|
|
3292
|
+
"january",
|
|
3293
|
+
"february",
|
|
3294
|
+
"march",
|
|
3295
|
+
"april",
|
|
3242
3296
|
"may",
|
|
3243
|
-
"
|
|
3244
|
-
"
|
|
3245
|
-
"
|
|
3246
|
-
"
|
|
3247
|
-
"
|
|
3248
|
-
"
|
|
3249
|
-
"
|
|
3297
|
+
"june",
|
|
3298
|
+
"july",
|
|
3299
|
+
"august",
|
|
3300
|
+
"september",
|
|
3301
|
+
"october",
|
|
3302
|
+
"november",
|
|
3303
|
+
"december"
|
|
3250
3304
|
];
|
|
3251
3305
|
const WEEKDAYS = [
|
|
3252
|
-
"
|
|
3253
|
-
"
|
|
3254
|
-
"
|
|
3255
|
-
"
|
|
3256
|
-
"
|
|
3257
|
-
"
|
|
3258
|
-
"
|
|
3306
|
+
"sunday",
|
|
3307
|
+
"monday",
|
|
3308
|
+
"tuesday",
|
|
3309
|
+
"wednesday",
|
|
3310
|
+
"thursday",
|
|
3311
|
+
"friday",
|
|
3312
|
+
"saturday"
|
|
3259
3313
|
];
|
|
3260
3314
|
/**
|
|
3261
3315
|
* The Sentry monitor config for a cron expression, or `undefined` if Sentry would read it differently.
|
|
3262
3316
|
* Without a `timezone`, the server's time zone is used, like the schedulers do.
|
|
3263
3317
|
*/
|
|
3264
|
-
function cronExpressionToMonitorConfig(expression, timezone,
|
|
3318
|
+
function cronExpressionToMonitorConfig(expression, timezone, dialect) {
|
|
3265
3319
|
const trimmed = expression.trim();
|
|
3266
|
-
const fields = (NICKNAMES[trimmed.toLowerCase()] || trimmed).split(/\s+/);
|
|
3320
|
+
const fields = (NICKNAMES[dialect][trimmed.toLowerCase()] || trimmed).split(/\s+/);
|
|
3267
3321
|
if (fields.length === 6 && /^\d+$/.test(fields[0])) fields.shift();
|
|
3268
|
-
if (fields.length !== 5 || !fields.every((field) => /^[\d*,/a-z
|
|
3269
|
-
const [minute, hour, dayOfMonth, month,
|
|
3270
|
-
const
|
|
3271
|
-
|
|
3322
|
+
if (fields.length !== 5 || !fields.every((field) => /^[\d*,/a-z#-]+$/i.test(field))) return;
|
|
3323
|
+
const [minute, hour, dayOfMonth, month, dayOfWeek] = fields;
|
|
3324
|
+
const monthNumbers = replaceNames(month, MONTHS, 1, dialect);
|
|
3325
|
+
const weekdayNames = replaceNames(dayOfWeek, WEEKDAYS, 0, dialect);
|
|
3326
|
+
const weekdayNumbers = dialect === "node-cron" ? endRangesOnSundayAsSeven(weekdayNames) : weekdayNames;
|
|
3272
3327
|
const crontab = [
|
|
3273
3328
|
minute,
|
|
3274
3329
|
hour,
|
|
3275
3330
|
dayOfMonth,
|
|
3276
|
-
|
|
3277
|
-
|
|
3331
|
+
monthNumbers,
|
|
3332
|
+
weekdayNumbers
|
|
3278
3333
|
];
|
|
3279
|
-
if (crontab.some((field) =>
|
|
3334
|
+
if (crontab.some((field, index) => hasUnsupportedCharacter(field, dialect === "cron-parser" ? CRON_PARSER_DAY_TOKENS[index] : void 0) || hasReversedRange(field) || hasSteppedSingleValueRange(field)) || !isSameDayMatching(dayOfMonth, weekdayNumbers, dialect) || !hasDayInSelectedMonths(dayOfMonth, monthNumbers)) return;
|
|
3280
3335
|
const sentryTimezone = toSentryTimezone(typeof timezone === "string" && timezone ? timezone : void 0);
|
|
3281
3336
|
if (!sentryTimezone) return;
|
|
3282
3337
|
return {
|
|
@@ -3287,31 +3342,93 @@ function cronExpressionToMonitorConfig(expression, timezone, daySemantics) {
|
|
|
3287
3342
|
timezone: sentryTimezone
|
|
3288
3343
|
};
|
|
3289
3344
|
}
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3345
|
+
const CRON_PARSER_DAY_TOKENS = [
|
|
3346
|
+
void 0,
|
|
3347
|
+
void 0,
|
|
3348
|
+
/^L$/,
|
|
3349
|
+
void 0,
|
|
3350
|
+
/^[0-7](?:L|#[1-5])$/
|
|
3351
|
+
];
|
|
3352
|
+
function hasUnsupportedCharacter(field, dayToken) {
|
|
3353
|
+
return field.split(",").some((part) => /[a-z#]/i.test(part) && !dayToken?.test(part));
|
|
3354
|
+
}
|
|
3355
|
+
function isSameDayMatching(dayOfMonth, dayOfWeek, dialect) {
|
|
3356
|
+
const monthDays = parseDayField(dayOfMonth, 1, 31);
|
|
3357
|
+
const weekdays = parseDayField(dayOfWeek, 0, 7);
|
|
3358
|
+
if (!monthDays || !weekdays) return false;
|
|
3359
|
+
const sentryNeedsBoth = dayOfMonth.startsWith("*") || dayOfWeek.startsWith("*");
|
|
3360
|
+
if (dialect === "cron-parser") return isSameDayMatchingInCronParser(dayOfMonth, dayOfWeek, monthDays, weekdays, sentryNeedsBoth);
|
|
3361
|
+
const allMonthDays = monthDays.days === 31;
|
|
3362
|
+
const allWeekdays = weekdays.days === 7;
|
|
3363
|
+
return allMonthDays && allWeekdays || (dialect === "node-cron" || allMonthDays || allWeekdays) === sentryNeedsBoth;
|
|
3364
|
+
}
|
|
3365
|
+
function isSameDayMatchingInCronParser(dayOfMonth, dayOfWeek, monthDays, weekdays, sentryNeedsBoth) {
|
|
3366
|
+
if (weekdays.cronParserAddsSunday || dayOfWeek.includes("#") && (dayOfMonth !== "*" || dayOfWeek.includes(","))) return false;
|
|
3367
|
+
if (dayOfWeek === "*") return true;
|
|
3368
|
+
if (dayOfMonth === "*") return weekdays.cronParserValues !== 8 || weekdays.days === 7;
|
|
3369
|
+
return !sentryNeedsBoth && monthDays.cronParserValues < 29 && weekdays.cronParserValues !== 8;
|
|
3370
|
+
}
|
|
3371
|
+
const DAYS_IN_MONTH = [
|
|
3372
|
+
31,
|
|
3373
|
+
29,
|
|
3374
|
+
31,
|
|
3375
|
+
30,
|
|
3376
|
+
31,
|
|
3377
|
+
30,
|
|
3378
|
+
31,
|
|
3379
|
+
31,
|
|
3380
|
+
30,
|
|
3381
|
+
31,
|
|
3382
|
+
30,
|
|
3383
|
+
31
|
|
3384
|
+
];
|
|
3385
|
+
function hasDayInSelectedMonths(dayOfMonth, month) {
|
|
3386
|
+
const days = parseDayField(dayOfMonth, 1, 31)?.values;
|
|
3387
|
+
const months = parseDayField(month, 1, 12)?.values;
|
|
3388
|
+
if (!days || !months) return false;
|
|
3389
|
+
return !days.size || Math.min(...days) <= Math.max(...[...months].map((m) => DAYS_IN_MONTH[m - 1]));
|
|
3390
|
+
}
|
|
3391
|
+
function parseDayField(field, low, high) {
|
|
3392
|
+
const days = /* @__PURE__ */ new Set();
|
|
3393
|
+
let cronParserValues = 0;
|
|
3394
|
+
let cronParserListsSunday = false;
|
|
3297
3395
|
for (const part of field.split(",")) {
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
const
|
|
3303
|
-
|
|
3396
|
+
if (/^(?:L|[0-7](?:L|#[1-5]))$/.test(part)) {
|
|
3397
|
+
cronParserValues++;
|
|
3398
|
+
continue;
|
|
3399
|
+
}
|
|
3400
|
+
const match = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/.exec(part);
|
|
3401
|
+
if (!match) return;
|
|
3402
|
+
const [, wildcard, from, to, step] = match;
|
|
3403
|
+
const lower = wildcard ? low : Number(from);
|
|
3404
|
+
const upper = wildcard || step && !to ? high : Number(to ?? from);
|
|
3405
|
+
const increment = Number(step ?? 1);
|
|
3406
|
+
if (!increment || lower < low || upper > high || lower > upper) return;
|
|
3407
|
+
if (high === 7 && upper === 7 && lower !== 0 && (to || step)) {
|
|
3408
|
+
cronParserValues++;
|
|
3409
|
+
cronParserListsSunday = true;
|
|
3410
|
+
}
|
|
3411
|
+
for (let day = lower; day <= upper; day += increment) {
|
|
3412
|
+
days.add(high === 7 && day === 7 ? 0 : day);
|
|
3413
|
+
cronParserValues++;
|
|
3414
|
+
}
|
|
3304
3415
|
}
|
|
3305
|
-
return
|
|
3416
|
+
return {
|
|
3417
|
+
values: days,
|
|
3418
|
+
days: days.size,
|
|
3419
|
+
cronParserValues,
|
|
3420
|
+
cronParserAddsSunday: cronParserListsSunday && !days.has(0)
|
|
3421
|
+
};
|
|
3306
3422
|
}
|
|
3307
|
-
function replaceNames(field, names, offset) {
|
|
3423
|
+
function replaceNames(field, names, offset, dialect) {
|
|
3308
3424
|
return field.replace(/[a-z]+/gi, (word) => {
|
|
3309
|
-
const
|
|
3425
|
+
const lowerCase = word.toLowerCase();
|
|
3426
|
+
const index = names.findIndex((name) => lowerCase === name.slice(0, 3) || dialect === "node-cron" && lowerCase === name);
|
|
3310
3427
|
return index === -1 ? word : String(index + offset);
|
|
3311
3428
|
});
|
|
3312
3429
|
}
|
|
3313
3430
|
function endRangesOnSundayAsSeven(field) {
|
|
3314
|
-
return field.replace(
|
|
3431
|
+
return field.split(",").map((part) => part.replace(/^(\d+)-0(?!\d)/, (range, start) => Number(start) ? `${start}-7` : range)).join(",");
|
|
3315
3432
|
}
|
|
3316
3433
|
function hasReversedRange(field) {
|
|
3317
3434
|
return field.split(",").some((part) => {
|
|
@@ -3319,6 +3436,12 @@ function hasReversedRange(field) {
|
|
|
3319
3436
|
return !!range && Number(range[1]) > Number(range[2]);
|
|
3320
3437
|
});
|
|
3321
3438
|
}
|
|
3439
|
+
function hasSteppedSingleValueRange(field) {
|
|
3440
|
+
return field.split(",").some((part) => {
|
|
3441
|
+
const range = /^(\d+)-(\d+)\//.exec(part);
|
|
3442
|
+
return !!range && Number(range[1]) === Number(range[2]);
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3322
3445
|
function toSentryTimezone(timezone) {
|
|
3323
3446
|
if (timezone && /^(?:utc|gmt)?[+-]/i.test(timezone)) return;
|
|
3324
3447
|
try {
|
|
@@ -3354,7 +3477,7 @@ function wrapScheduledJob(func, monitorSlug, monitorConfig, mechanismType) {
|
|
|
3354
3477
|
return (0, _sentry_core.startNewTrace)(() => currentConfig ? (0, _sentry_core.withMonitor)(monitorSlug, run, currentConfig) : run());
|
|
3355
3478
|
};
|
|
3356
3479
|
monitorConfigs.set(wrapped, monitorConfig);
|
|
3357
|
-
(0, _sentry_core.addNonEnumerableProperty)(wrapped, MONITORED, true);
|
|
3480
|
+
(0, _sentry_core.addNonEnumerableProperty)(wrapped, MONITORED$1, true);
|
|
3358
3481
|
return wrapped;
|
|
3359
3482
|
}
|
|
3360
3483
|
/** Sets the monitor config a job from `wrapScheduledJob` sends on its next runs. Other functions are ignored. */
|
|
@@ -3386,7 +3509,7 @@ function onSetTime({ arguments: [cronTime], self }) {
|
|
|
3386
3509
|
const job = self;
|
|
3387
3510
|
if (!job || job.cronTime !== cronTime) return;
|
|
3388
3511
|
const { source, timeZone, utcOffset } = cronTime;
|
|
3389
|
-
const monitorConfig = typeof source === "string" && utcOffset == null ? cronExpressionToMonitorConfig(source, timeZone, "
|
|
3512
|
+
const monitorConfig = typeof source === "string" && utcOffset == null ? cronExpressionToMonitorConfig(source, timeZone, "cron") : void 0;
|
|
3390
3513
|
for (const callback of job._callbacks || []) updateMonitorConfig(callback, monitorConfig);
|
|
3391
3514
|
}
|
|
3392
3515
|
function wrapJob(args, options) {
|
|
@@ -3394,7 +3517,7 @@ function wrapJob(args, options) {
|
|
|
3394
3517
|
const utcOffset = args[7];
|
|
3395
3518
|
const name = args[11];
|
|
3396
3519
|
if (typeof cronTime !== "string" || !shouldMonitorJob(name, onTick, options.excludeJobs)) return;
|
|
3397
|
-
args[1] = wrapScheduledJob(onTick, name, utcOffset == null ? cronExpressionToMonitorConfig(cronTime, timeZone, "
|
|
3520
|
+
args[1] = wrapScheduledJob(onTick, name, utcOffset == null ? cronExpressionToMonitorConfig(cronTime, timeZone, "cron") : void 0, "auto.function.cron");
|
|
3398
3521
|
}
|
|
3399
3522
|
// src/integrations/node-cron.ts
|
|
3400
3523
|
const INTEGRATION_NAME$26 = "NodeCron";
|
|
@@ -3425,7 +3548,7 @@ function wrapTask(args, options, isReadAlike) {
|
|
|
3425
3548
|
}
|
|
3426
3549
|
/** The monitor config for a task, or `undefined` if `isReadAlike` says this node-cron version reads it differently. */
|
|
3427
3550
|
function getMonitorConfig$1(expression, timezone, isReadAlike) {
|
|
3428
|
-
return isReadAlike && !isReadAlike(expression) ? void 0 : cronExpressionToMonitorConfig(expression, timezone, "
|
|
3551
|
+
return isReadAlike && !isReadAlike(expression) ? void 0 : cronExpressionToMonitorConfig(expression, timezone, "node-cron");
|
|
3429
3552
|
}
|
|
3430
3553
|
const NODE_CRON_3_FIELD_MINIMUMS = [
|
|
3431
3554
|
0,
|
|
@@ -3436,11 +3559,12 @@ const NODE_CRON_3_FIELD_MINIMUMS = [
|
|
|
3436
3559
|
];
|
|
3437
3560
|
/**
|
|
3438
3561
|
* node-cron before 4.6 reads `7` as `0` and swaps reversed ranges, so it runs `sat-sun`, `6-0` and `6-7` every day.
|
|
3439
|
-
* Returns `false`
|
|
3562
|
+
* It also reads a step without a range, like `5/10`, as its start. Returns `false` where that could differ.
|
|
3440
3563
|
*/
|
|
3441
3564
|
function isReadAlikeByNodeCron4(expression) {
|
|
3442
|
-
const
|
|
3443
|
-
|
|
3565
|
+
const fields = expression.trim().split(/\s+/);
|
|
3566
|
+
const weekday = fields[fields.length - 1] || "";
|
|
3567
|
+
return !(weekday.includes("-") && (weekday.includes("7") || /-(?:0|sun)/i.test(weekday))) && !fields.some((field) => field.split(",").some((part) => /^[a-z\d]+\//i.test(part)));
|
|
3444
3568
|
}
|
|
3445
3569
|
/**
|
|
3446
3570
|
* node-cron 3 keeps the values of a stepped field that are multiples of the step (`*\/2` days are 2, 4, ...)
|
|
@@ -3507,10 +3631,524 @@ function isCronShaped(value) {
|
|
|
3507
3631
|
return /^@[a-z]+$/i.test(value.trim()) || (fields.length === 5 || fields.length === 6) && fields.every((field) => /^[\d*,/?#a-z-]+$/i.test(field));
|
|
3508
3632
|
}
|
|
3509
3633
|
function getMonitorConfig(spec) {
|
|
3510
|
-
if (typeof spec === "string") return cronExpressionToMonitorConfig(spec, void 0, "
|
|
3634
|
+
if (typeof spec === "string") return cronExpressionToMonitorConfig(spec, void 0, "cron-parser");
|
|
3511
3635
|
const { rule, tz, start, end } = spec || {};
|
|
3512
|
-
return typeof rule === "string" && !start && !end ? cronExpressionToMonitorConfig(rule, tz, "
|
|
3636
|
+
return typeof rule === "string" && !start && !end ? cronExpressionToMonitorConfig(rule, tz, "cron-parser") : void 0;
|
|
3637
|
+
}
|
|
3638
|
+
// src/cron/common.ts
|
|
3639
|
+
/**
|
|
3640
|
+
* The monitor config for a cron expression, or `undefined` if Sentry would read the expression differently than the
|
|
3641
|
+
* scheduler runs it.
|
|
3642
|
+
*/
|
|
3643
|
+
function getCronMonitorConfig(expression, timezone, dialect, isReadAlike = () => true) {
|
|
3644
|
+
const monitorConfig = isReadAlike(expression) ? cronExpressionToMonitorConfig(expression, timezone, dialect) : void 0;
|
|
3645
|
+
if (!monitorConfig) require_debug_build.DEBUG_BUILD && _sentry_core.debug.warn(`[Cron] Can't convert "${expression}" to a Sentry schedule, sending check-ins without a monitor config.`);
|
|
3646
|
+
return monitorConfig;
|
|
3647
|
+
}
|
|
3648
|
+
// src/cron/cron.ts
|
|
3649
|
+
const MONITORED = Symbol.for("sentry.cron.monitored");
|
|
3650
|
+
const ERROR_TEXT = "Automatic instrumentation of CronJob only supports crontab string";
|
|
3651
|
+
/**
|
|
3652
|
+
* Instruments the `cron` library to send a check-in event to Sentry for each job execution.
|
|
3653
|
+
*
|
|
3654
|
+
* ```ts
|
|
3655
|
+
* import * as Sentry from '@sentry/node';
|
|
3656
|
+
* import { CronJob } from 'cron';
|
|
3657
|
+
*
|
|
3658
|
+
* const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'my-cron-job');
|
|
3659
|
+
*
|
|
3660
|
+
* // use the constructor
|
|
3661
|
+
* const job = new CronJobWithCheckIn('* * * * *', () => {
|
|
3662
|
+
* console.log('You will see this message every minute');
|
|
3663
|
+
* });
|
|
3664
|
+
*
|
|
3665
|
+
* // or from
|
|
3666
|
+
* const job = CronJobWithCheckIn.from({ cronTime: '* * * * *', onTick: () => {
|
|
3667
|
+
* console.log('You will see this message every minute');
|
|
3668
|
+
* });
|
|
3669
|
+
* ```
|
|
3670
|
+
*
|
|
3671
|
+
* @deprecated Use `cronJobIntegration` instead.
|
|
3672
|
+
*/
|
|
3673
|
+
function instrumentCron(lib, monitorSlug) {
|
|
3674
|
+
let jobScheduled = false;
|
|
3675
|
+
return new Proxy(lib, {
|
|
3676
|
+
construct(target, args) {
|
|
3677
|
+
const [cronTime, onTick, onComplete, start, timeZone, ...rest] = args;
|
|
3678
|
+
if (typeof cronTime !== "string") throw new Error(ERROR_TEXT);
|
|
3679
|
+
if (jobScheduled) throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
|
|
3680
|
+
jobScheduled = true;
|
|
3681
|
+
const monitorConfig = args[7] == null ? getCronMonitorConfig(cronTime, timeZone, "cron") : void 0;
|
|
3682
|
+
async function monitoredTick(context, onComplete) {
|
|
3683
|
+
return (0, _sentry_core.withMonitor)(monitorSlug, async () => {
|
|
3684
|
+
try {
|
|
3685
|
+
await onTick(context, onComplete);
|
|
3686
|
+
} catch (e) {
|
|
3687
|
+
(0, _sentry_core.captureException)(e, { mechanism: {
|
|
3688
|
+
handled: false,
|
|
3689
|
+
type: "auto.function.cron.instrumentCron"
|
|
3690
|
+
} });
|
|
3691
|
+
throw e;
|
|
3692
|
+
}
|
|
3693
|
+
}, monitorConfig);
|
|
3694
|
+
}
|
|
3695
|
+
(0, _sentry_core.addNonEnumerableProperty)(monitoredTick, MONITORED, true);
|
|
3696
|
+
return new target(cronTime, monitoredTick, onComplete, start, timeZone, ...rest);
|
|
3697
|
+
},
|
|
3698
|
+
get(target, prop) {
|
|
3699
|
+
if (prop === "from") return (param) => {
|
|
3700
|
+
const { cronTime, onTick, timeZone, utcOffset } = param;
|
|
3701
|
+
if (typeof cronTime !== "string") throw new Error(ERROR_TEXT);
|
|
3702
|
+
if (jobScheduled) throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
|
|
3703
|
+
jobScheduled = true;
|
|
3704
|
+
const monitorConfig = utcOffset == null ? getCronMonitorConfig(cronTime, timeZone, "cron") : void 0;
|
|
3705
|
+
param.onTick = async (context, onComplete) => {
|
|
3706
|
+
return (0, _sentry_core.withMonitor)(monitorSlug, async () => {
|
|
3707
|
+
try {
|
|
3708
|
+
await onTick(context, onComplete);
|
|
3709
|
+
} catch (e) {
|
|
3710
|
+
(0, _sentry_core.captureException)(e, { mechanism: {
|
|
3711
|
+
handled: false,
|
|
3712
|
+
type: "auto.function.cron.instrumentCron"
|
|
3713
|
+
} });
|
|
3714
|
+
throw e;
|
|
3715
|
+
}
|
|
3716
|
+
}, monitorConfig);
|
|
3717
|
+
};
|
|
3718
|
+
(0, _sentry_core.addNonEnumerableProperty)(param.onTick, MONITORED, true);
|
|
3719
|
+
return target.from(param);
|
|
3720
|
+
};
|
|
3721
|
+
else return target[prop];
|
|
3722
|
+
}
|
|
3723
|
+
});
|
|
3724
|
+
}
|
|
3725
|
+
// src/cron/node-cron.ts
|
|
3726
|
+
/**
|
|
3727
|
+
* Wraps the `node-cron` library with check-in monitoring.
|
|
3728
|
+
*
|
|
3729
|
+
* ```ts
|
|
3730
|
+
* import * as Sentry from "@sentry/node";
|
|
3731
|
+
* import * as cron from "node-cron";
|
|
3732
|
+
*
|
|
3733
|
+
* const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);
|
|
3734
|
+
*
|
|
3735
|
+
* cronWithCheckIn.schedule(
|
|
3736
|
+
* "* * * * *",
|
|
3737
|
+
* () => {
|
|
3738
|
+
* console.log("running a task every minute");
|
|
3739
|
+
* },
|
|
3740
|
+
* { name: "my-cron-job" },
|
|
3741
|
+
* );
|
|
3742
|
+
* ```
|
|
3743
|
+
*
|
|
3744
|
+
* On node-cron 4, steps on `*` in the day-of-month or month field (such as every second day) aren't sent as a
|
|
3745
|
+
* schedule, because this wrapper can't tell the node-cron version. `nodeCronIntegration` can.
|
|
3746
|
+
*
|
|
3747
|
+
* @deprecated Use `nodeCronIntegration` instead.
|
|
3748
|
+
*/
|
|
3749
|
+
function instrumentNodeCron(lib, monitorConfig = {}) {
|
|
3750
|
+
return new Proxy(lib, { get(target, prop) {
|
|
3751
|
+
if (prop === "schedule" && target.schedule) return new Proxy(target.schedule, { apply(target, thisArg, argArray) {
|
|
3752
|
+
const [expression, callback, options] = argArray;
|
|
3753
|
+
const name = options?.name;
|
|
3754
|
+
const timezone = options?.timezone;
|
|
3755
|
+
if (!name) throw new Error("Missing \"name\" for scheduled job. A name is required for Sentry check-in monitoring.");
|
|
3756
|
+
const cronConfig = getCronMonitorConfig(expression, timezone, "node-cron", isReadAlikeByNodeCron3);
|
|
3757
|
+
const upsertMonitorConfig = cronConfig && {
|
|
3758
|
+
...cronConfig,
|
|
3759
|
+
...monitorConfig
|
|
3760
|
+
};
|
|
3761
|
+
const monitoredCallback = async (...args) => {
|
|
3762
|
+
const runWithMonitor = () => (0, _sentry_core.withMonitor)(name, async () => {
|
|
3763
|
+
try {
|
|
3764
|
+
return await callback(...args);
|
|
3765
|
+
} catch (e) {
|
|
3766
|
+
(0, _sentry_core.captureException)(e, { mechanism: {
|
|
3767
|
+
handled: false,
|
|
3768
|
+
type: "auto.function.node-cron.instrumentNodeCron"
|
|
3769
|
+
} });
|
|
3770
|
+
throw e;
|
|
3771
|
+
}
|
|
3772
|
+
}, upsertMonitorConfig);
|
|
3773
|
+
return !upsertMonitorConfig && monitorConfig.isolateTrace ? (0, _sentry_core.startNewTrace)(runWithMonitor) : runWithMonitor();
|
|
3774
|
+
};
|
|
3775
|
+
(0, _sentry_core.addNonEnumerableProperty)(monitoredCallback, Symbol.for("sentry.cron.monitored"), true);
|
|
3776
|
+
return target.apply(thisArg, [
|
|
3777
|
+
expression,
|
|
3778
|
+
monitoredCallback,
|
|
3779
|
+
options
|
|
3780
|
+
]);
|
|
3781
|
+
} });
|
|
3782
|
+
else return target[prop];
|
|
3783
|
+
} });
|
|
3784
|
+
}
|
|
3785
|
+
// src/cron/node-schedule.ts
|
|
3786
|
+
/**
|
|
3787
|
+
* Instruments the `node-schedule` library to send a check-in event to Sentry for each job execution.
|
|
3788
|
+
*
|
|
3789
|
+
* ```ts
|
|
3790
|
+
* import * as Sentry from '@sentry/node';
|
|
3791
|
+
* import * as schedule from 'node-schedule';
|
|
3792
|
+
*
|
|
3793
|
+
* const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);
|
|
3794
|
+
*
|
|
3795
|
+
* const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * *', () => {
|
|
3796
|
+
* console.log('You will see this message every minute');
|
|
3797
|
+
* });
|
|
3798
|
+
* ```
|
|
3799
|
+
*/
|
|
3800
|
+
function instrumentNodeSchedule(lib) {
|
|
3801
|
+
return new Proxy(lib, { get(target, prop) {
|
|
3802
|
+
if (prop === "scheduleJob") return new Proxy(target.scheduleJob, { apply(target, thisArg, argArray) {
|
|
3803
|
+
const [nameOrExpression, expressionOrCallback, callback] = argArray;
|
|
3804
|
+
if (typeof nameOrExpression !== "string" || typeof expressionOrCallback !== "string" || typeof callback !== "function") throw new Error("Automatic instrumentation of 'node-schedule' requires the first parameter of 'scheduleJob' to be a job name string and the second parameter to be a crontab string");
|
|
3805
|
+
const monitorSlug = nameOrExpression;
|
|
3806
|
+
const expression = expressionOrCallback;
|
|
3807
|
+
const monitorConfig = getCronMonitorConfig(expression, void 0, "cron-parser");
|
|
3808
|
+
async function monitoredCallback() {
|
|
3809
|
+
return (0, _sentry_core.withMonitor)(monitorSlug, async () => {
|
|
3810
|
+
await callback?.();
|
|
3811
|
+
}, monitorConfig);
|
|
3812
|
+
}
|
|
3813
|
+
(0, _sentry_core.addNonEnumerableProperty)(monitoredCallback, Symbol.for("sentry.cron.monitored"), true);
|
|
3814
|
+
return target.apply(thisArg, [
|
|
3815
|
+
monitorSlug,
|
|
3816
|
+
expression,
|
|
3817
|
+
monitoredCallback
|
|
3818
|
+
]);
|
|
3819
|
+
} });
|
|
3820
|
+
return target[prop];
|
|
3821
|
+
} });
|
|
3513
3822
|
}
|
|
3823
|
+
// src/cron/index.ts
|
|
3824
|
+
/** Methods to instrument cron libraries for Sentry check-ins */
|
|
3825
|
+
const cron = {
|
|
3826
|
+
instrumentCron,
|
|
3827
|
+
instrumentNodeCron,
|
|
3828
|
+
instrumentNodeSchedule
|
|
3829
|
+
};
|
|
3830
|
+
// src/integrations/bullmq/contextManager.ts
|
|
3831
|
+
var SentryBullMQContextManager = class {
|
|
3832
|
+
active() {
|
|
3833
|
+
return {
|
|
3834
|
+
span: (0, _sentry_core.getActiveSpan)(),
|
|
3835
|
+
scope: (0, _sentry_core.getCurrentScope)()
|
|
3836
|
+
};
|
|
3837
|
+
}
|
|
3838
|
+
with(context, fn) {
|
|
3839
|
+
if (context.span) return (0, _sentry_core.withIsolationScope)(() => {
|
|
3840
|
+
return (0, _sentry_core.withActiveSpan)(context.span, fn);
|
|
3841
|
+
});
|
|
3842
|
+
return (0, _sentry_core.withIsolationScope)(() => (0, _sentry_core.withActiveSpan)(null, fn));
|
|
3843
|
+
}
|
|
3844
|
+
/**
|
|
3845
|
+
* Returns a context without a span. BullMQ 6.3.11+ runs the stalled jobs checker in it, so the
|
|
3846
|
+
* checker does not stay attached to the span that was active when the worker started.
|
|
3847
|
+
*/
|
|
3848
|
+
root() {
|
|
3849
|
+
return {
|
|
3850
|
+
span: void 0,
|
|
3851
|
+
scope: (0, _sentry_core.getCurrentScope)()
|
|
3852
|
+
};
|
|
3853
|
+
}
|
|
3854
|
+
getMetadata(context) {
|
|
3855
|
+
if (context.span) return (0, _sentry_core.spanToTraceHeader)(context.span);
|
|
3856
|
+
return "";
|
|
3857
|
+
}
|
|
3858
|
+
fromMetadata(activeContext, metadata) {
|
|
3859
|
+
const traceparent = (0, _sentry_core.extractTraceparentData)(metadata);
|
|
3860
|
+
if (!traceparent?.traceId || !traceparent?.parentSpanId) return activeContext;
|
|
3861
|
+
return {
|
|
3862
|
+
...activeContext,
|
|
3863
|
+
producerSpanContext: {
|
|
3864
|
+
traceId: traceparent.traceId,
|
|
3865
|
+
spanId: traceparent.parentSpanId,
|
|
3866
|
+
sampled: traceparent.parentSampled === true
|
|
3867
|
+
}
|
|
3868
|
+
};
|
|
3869
|
+
}
|
|
3870
|
+
};
|
|
3871
|
+
// src/integrations/bullmq/span.ts
|
|
3872
|
+
const DROPPED_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
3873
|
+
"bullmq.job.options",
|
|
3874
|
+
"bullmq.job.progress",
|
|
3875
|
+
"bullmq.queue.options",
|
|
3876
|
+
"bullmq.worker.options",
|
|
3877
|
+
"bullmq.job.finished.timestamp"
|
|
3878
|
+
]);
|
|
3879
|
+
const MESSAGING_BULLMQ_KEYS = /* @__PURE__ */ new Map([
|
|
3880
|
+
["bullmq.flow.name", _sentry_conventions_attributes.MESSAGING_BULLMQ_FLOW_NAME],
|
|
3881
|
+
["bullmq.job.attempt_finished_timestamp", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_ATTEMPT_FINISHED_TIMESTAMP],
|
|
3882
|
+
["bullmq.job.bulk.names", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_BULK_NAMES],
|
|
3883
|
+
["bullmq.job.deduplication.key", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_DEDUPLICATION_KEY],
|
|
3884
|
+
["bullmq.job.ids", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_IDS],
|
|
3885
|
+
["bullmq.job.key", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_KEY],
|
|
3886
|
+
["bullmq.job.name", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_NAME],
|
|
3887
|
+
["bullmq.job.processed.timestamp", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_PROCESSED_TIMESTAMP],
|
|
3888
|
+
["bullmq.job.scheduler.id", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_SCHEDULER_ID],
|
|
3889
|
+
["bullmq.job.type", _sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_TYPE],
|
|
3890
|
+
["bullmq.queue.clean.count", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_CLEAN_COUNT],
|
|
3891
|
+
["bullmq.queue.clean.limit", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_CLEAN_LIMIT],
|
|
3892
|
+
["bullmq.queue.drain.delay", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_DRAIN_DELAY],
|
|
3893
|
+
["bullmq.queue.event.max.length", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_EVENT_MAX_LENGTH],
|
|
3894
|
+
["bullmq.queue.grace", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_GRACE],
|
|
3895
|
+
["bullmq.queue.jobs.state", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_JOBS_STATE],
|
|
3896
|
+
["bullmq.queue.rate.limit", _sentry_conventions_attributes.MESSAGING_BULLMQ_QUEUE_RATE_LIMIT],
|
|
3897
|
+
["bullmq.worker.do.not.wait.active", _sentry_conventions_attributes.MESSAGING_BULLMQ_WORKER_DO_NOT_WAIT_ACTIVE],
|
|
3898
|
+
["bullmq.worker.force.close", _sentry_conventions_attributes.MESSAGING_BULLMQ_WORKER_FORCE_CLOSE],
|
|
3899
|
+
["bullmq.worker.jobs.to.extend.locks", _sentry_conventions_attributes.MESSAGING_BULLMQ_WORKER_JOBS_TO_EXTEND_LOCKS],
|
|
3900
|
+
["bullmq.worker.name", _sentry_conventions_attributes.MESSAGING_BULLMQ_WORKER_NAME],
|
|
3901
|
+
["bullmq.worker.rate.limit", _sentry_conventions_attributes.MESSAGING_BULLMQ_WORKER_RATE_LIMIT],
|
|
3902
|
+
["bullmq.worker.stalled.jobs", _sentry_conventions_attributes.MESSAGING_BULLMQ_WORKER_STALLED_JOBS]
|
|
3903
|
+
]);
|
|
3904
|
+
/**
|
|
3905
|
+
* Returns the Sentry key for a `bullmq.*` attribute key or metric name: the key from `MESSAGING_BULLMQ_KEYS`, or
|
|
3906
|
+
* `messaging.<key>` for the keys that are not in it, such as the metric names. Returns all other keys unchanged.
|
|
3907
|
+
*/
|
|
3908
|
+
function toMessagingKey(key) {
|
|
3909
|
+
return MESSAGING_BULLMQ_KEYS.get(key) ?? (key.startsWith("bullmq.") ? `messaging.${key}` : key);
|
|
3910
|
+
}
|
|
3911
|
+
/**
|
|
3912
|
+
* Returns the BullMQ attributes with Sentry keys: the `messaging.*` convention where one exists, and the
|
|
3913
|
+
* `messaging.bullmq.*` key for all others. The attributes that hold JSON strings and the deprecated ones are left out.
|
|
3914
|
+
*/
|
|
3915
|
+
function toSentryAttributes(attributes) {
|
|
3916
|
+
const { "bullmq.queue.name": queueName, "bullmq.queue.operation": operation, "bullmq.job.id": jobId, "bullmq.job.attempts.made": attemptsMade, "bullmq.job.bulk.count": bulkCount, "bullmq.worker.id": workerId, "bullmq.job.state": jobState, "bullmq.job.status": jobStatus, ...rest } = attributes;
|
|
3917
|
+
const result = {};
|
|
3918
|
+
for (const [key, value] of Object.entries(rest)) if (!DROPPED_ATTRIBUTES.has(key)) result[toMessagingKey(key)] = value;
|
|
3919
|
+
if (typeof queueName === "string") result[_sentry_conventions_attributes.MESSAGING_DESTINATION_NAME] = queueName;
|
|
3920
|
+
if (typeof operation === "string") result[_sentry_conventions_attributes.MESSAGING_OPERATION_NAME] = operation;
|
|
3921
|
+
if (jobId !== void 0) result[_sentry_conventions_attributes.MESSAGING_MESSAGE_ID] = String(jobId);
|
|
3922
|
+
if (typeof attemptsMade === "number") result[_sentry_conventions_attributes.MESSAGING_MESSAGE_RETRY_COUNT] = Math.max(attemptsMade - 1, 0);
|
|
3923
|
+
if (typeof bulkCount === "number") result[_sentry_conventions_attributes.MESSAGING_BATCH_MESSAGE_COUNT] = bulkCount;
|
|
3924
|
+
if (typeof workerId === "string") result[_sentry_conventions_attributes.MESSAGING_CLIENT_ID] = workerId;
|
|
3925
|
+
const state = jobState ?? jobStatus;
|
|
3926
|
+
if (typeof state === "string") result[_sentry_conventions_attributes.MESSAGING_BULLMQ_JOB_STATE] = state;
|
|
3927
|
+
return result;
|
|
3928
|
+
}
|
|
3929
|
+
var SentryBullMQSpan = class {
|
|
3930
|
+
constructor(span, scope) {
|
|
3931
|
+
this._span = span;
|
|
3932
|
+
this._scope = scope;
|
|
3933
|
+
}
|
|
3934
|
+
setAttribute(key, value) {
|
|
3935
|
+
this.setAttributes({ [key]: value });
|
|
3936
|
+
}
|
|
3937
|
+
setAttributes(attributes) {
|
|
3938
|
+
this._span.setAttributes(toSentryAttributes(attributes));
|
|
3939
|
+
}
|
|
3940
|
+
addEvent(name, attributes) {
|
|
3941
|
+
this._span.addEvent(name, attributes);
|
|
3942
|
+
if (name === "job failed") {
|
|
3943
|
+
this._span.setStatus({
|
|
3944
|
+
code: _sentry_core.SPAN_STATUS_ERROR,
|
|
3945
|
+
message: "internal_error"
|
|
3946
|
+
});
|
|
3947
|
+
let error = this._recordedError;
|
|
3948
|
+
this._recordedError = void 0;
|
|
3949
|
+
if (!error) {
|
|
3950
|
+
error = new Error(String(attributes?.["bullmq.job.failed.reason"] || "Unknown error"));
|
|
3951
|
+
error.stack = void 0;
|
|
3952
|
+
}
|
|
3953
|
+
(0, _sentry_core.captureException)(error, { mechanism: {
|
|
3954
|
+
handled: false,
|
|
3955
|
+
type: "auto.queue.bullmq"
|
|
3956
|
+
} });
|
|
3957
|
+
}
|
|
3958
|
+
}
|
|
3959
|
+
/**
|
|
3960
|
+
* Does not capture to Sentry. BullMQ calls this for Redis, lock and serialization errors that it
|
|
3961
|
+
* retries itself, often several times for one fault, and for the job error right before the `job failed` event.
|
|
3962
|
+
* Job failures are captured in `addEvent`.
|
|
3963
|
+
*/
|
|
3964
|
+
recordException(exception) {
|
|
3965
|
+
this._recordedError = exception instanceof Error ? exception : void 0;
|
|
3966
|
+
const error = this._recordedError ?? new Error(typeof exception === "string" ? exception : exception.message || "Unknown error");
|
|
3967
|
+
this._span.recordException(error);
|
|
3968
|
+
}
|
|
3969
|
+
setSpanOnContext(context) {
|
|
3970
|
+
return {
|
|
3971
|
+
...context,
|
|
3972
|
+
span: this._span,
|
|
3973
|
+
scope: this._scope
|
|
3974
|
+
};
|
|
3975
|
+
}
|
|
3976
|
+
end() {
|
|
3977
|
+
this._span.end();
|
|
3978
|
+
}
|
|
3979
|
+
};
|
|
3980
|
+
// src/integrations/bullmq/meter.ts
|
|
3981
|
+
function toMetricAttributes(attributes) {
|
|
3982
|
+
if (!attributes) return;
|
|
3983
|
+
const result = {};
|
|
3984
|
+
for (const [key, value] of Object.entries(toSentryAttributes(attributes))) if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") result[key] = value;
|
|
3985
|
+
return result;
|
|
3986
|
+
}
|
|
3987
|
+
/**
|
|
3988
|
+
* Converts the OpenTelemetry (UCUM) unit that BullMQ passes to the matching Sentry unit.
|
|
3989
|
+
*/
|
|
3990
|
+
function toSentryUnit(unit) {
|
|
3991
|
+
if (unit === "ms") return "millisecond";
|
|
3992
|
+
if (unit === "1" || unit?.startsWith("{")) return "none";
|
|
3993
|
+
return unit;
|
|
3994
|
+
}
|
|
3995
|
+
var SentryBullMQCounter = class {
|
|
3996
|
+
constructor(name, unit) {
|
|
3997
|
+
this._name = name;
|
|
3998
|
+
this._unit = unit;
|
|
3999
|
+
}
|
|
4000
|
+
add(value, attributes) {
|
|
4001
|
+
_sentry_core.metrics.count(this._name, value, {
|
|
4002
|
+
unit: this._unit,
|
|
4003
|
+
attributes: toMetricAttributes(attributes)
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
4006
|
+
};
|
|
4007
|
+
var SentryBullMQHistogram = class {
|
|
4008
|
+
constructor(name, unit) {
|
|
4009
|
+
this._name = name;
|
|
4010
|
+
this._unit = unit;
|
|
4011
|
+
}
|
|
4012
|
+
record(value, attributes) {
|
|
4013
|
+
_sentry_core.metrics.distribution(this._name, value, {
|
|
4014
|
+
unit: this._unit,
|
|
4015
|
+
attributes: toMetricAttributes(attributes)
|
|
4016
|
+
});
|
|
4017
|
+
}
|
|
4018
|
+
};
|
|
4019
|
+
var SentryBullMQGauge = class {
|
|
4020
|
+
constructor(name, unit) {
|
|
4021
|
+
this._name = name;
|
|
4022
|
+
this._unit = unit;
|
|
4023
|
+
}
|
|
4024
|
+
record(value, attributes) {
|
|
4025
|
+
_sentry_core.metrics.gauge(this._name, value, {
|
|
4026
|
+
unit: this._unit,
|
|
4027
|
+
attributes: toMetricAttributes(attributes)
|
|
4028
|
+
});
|
|
4029
|
+
}
|
|
4030
|
+
};
|
|
4031
|
+
/**
|
|
4032
|
+
* Records BullMQ's `bullmq.job.duration` histogram, which is in milliseconds, as the OTel
|
|
4033
|
+
* `messaging.process.duration` metric in seconds.
|
|
4034
|
+
*/
|
|
4035
|
+
var SentryBullMQProcessDuration = class {
|
|
4036
|
+
record(value, attributes) {
|
|
4037
|
+
_sentry_core.metrics.distribution(_sentry_conventions_metrics.MESSAGING_PROCESS_DURATION, value / 1e3, {
|
|
4038
|
+
unit: "second",
|
|
4039
|
+
attributes: {
|
|
4040
|
+
...toMetricAttributes(attributes),
|
|
4041
|
+
[_sentry_conventions_attributes.MESSAGING_SYSTEM]: "bullmq",
|
|
4042
|
+
[_sentry_conventions_attributes.MESSAGING_OPERATION_NAME]: "process"
|
|
4043
|
+
}
|
|
4044
|
+
});
|
|
4045
|
+
}
|
|
4046
|
+
};
|
|
4047
|
+
var SentryBullMQMeter = class {
|
|
4048
|
+
createCounter(name, options) {
|
|
4049
|
+
return new SentryBullMQCounter(toMessagingKey(name), toSentryUnit(options?.unit));
|
|
4050
|
+
}
|
|
4051
|
+
createHistogram(name, options) {
|
|
4052
|
+
if (name === "bullmq.job.duration") return new SentryBullMQProcessDuration();
|
|
4053
|
+
return new SentryBullMQHistogram(toMessagingKey(name), toSentryUnit(options?.unit));
|
|
4054
|
+
}
|
|
4055
|
+
createGauge(name, options) {
|
|
4056
|
+
return new SentryBullMQGauge(toMessagingKey(name), toSentryUnit(options?.unit));
|
|
4057
|
+
}
|
|
4058
|
+
};
|
|
4059
|
+
// src/integrations/bullmq/tracer.ts
|
|
4060
|
+
const PRODUCER_OPERATIONS = /* @__PURE__ */ new Set([
|
|
4061
|
+
"add",
|
|
4062
|
+
"addbulk",
|
|
4063
|
+
"addflow",
|
|
4064
|
+
"addbulkflows"
|
|
4065
|
+
]);
|
|
4066
|
+
const CONSUMER_OPERATIONS = /* @__PURE__ */ new Set(["process"]);
|
|
4067
|
+
function getOperation$1(name) {
|
|
4068
|
+
return name.split(" ")[0].toLowerCase();
|
|
4069
|
+
}
|
|
4070
|
+
function getOpFromSpanName(name) {
|
|
4071
|
+
const operation = getOperation$1(name);
|
|
4072
|
+
if (CONSUMER_OPERATIONS.has(operation)) return _sentry_conventions_op.QUEUE_PROCESS;
|
|
4073
|
+
if (PRODUCER_OPERATIONS.has(operation)) return _sentry_conventions_op.QUEUE_PUBLISH;
|
|
4074
|
+
return _sentry_conventions_op.QUEUE;
|
|
4075
|
+
}
|
|
4076
|
+
function getOriginFromSpanName(name) {
|
|
4077
|
+
const operation = getOperation$1(name);
|
|
4078
|
+
if (CONSUMER_OPERATIONS.has(operation)) return "auto.queue.bullmq.consumer";
|
|
4079
|
+
if (PRODUCER_OPERATIONS.has(operation)) return "auto.queue.bullmq.producer";
|
|
4080
|
+
return "auto.queue.bullmq";
|
|
4081
|
+
}
|
|
4082
|
+
var SentryBullMQTracer = class {
|
|
4083
|
+
startSpan(name, options, context) {
|
|
4084
|
+
const op = getOpFromSpanName(name);
|
|
4085
|
+
const origin = getOriginFromSpanName(name);
|
|
4086
|
+
const attributes = {
|
|
4087
|
+
[_sentry_conventions_attributes.SENTRY_OP]: op,
|
|
4088
|
+
[_sentry_conventions_attributes.SENTRY_ORIGIN]: origin,
|
|
4089
|
+
[_sentry_conventions_attributes.MESSAGING_SYSTEM]: "bullmq",
|
|
4090
|
+
...options?.attributes && toSentryAttributes(options.attributes)
|
|
4091
|
+
};
|
|
4092
|
+
const span = op === _sentry_conventions_op.QUEUE_PROCESS ? (0, _sentry_core.startNewTrace)(() => (0, _sentry_core.startInactiveSpan)({
|
|
4093
|
+
name,
|
|
4094
|
+
attributes
|
|
4095
|
+
})) : (0, _sentry_core.startInactiveSpan)({
|
|
4096
|
+
name,
|
|
4097
|
+
attributes,
|
|
4098
|
+
onlyIfParent: op === _sentry_conventions_op.QUEUE
|
|
4099
|
+
});
|
|
4100
|
+
if (context?.producerSpanContext) {
|
|
4101
|
+
const producerSpanCtx = {
|
|
4102
|
+
traceId: context.producerSpanContext.traceId,
|
|
4103
|
+
spanId: context.producerSpanContext.spanId,
|
|
4104
|
+
traceFlags: context.producerSpanContext.sampled ? 1 : 0
|
|
4105
|
+
};
|
|
4106
|
+
span.addLink({
|
|
4107
|
+
context: producerSpanCtx,
|
|
4108
|
+
attributes: { [_sentry_conventions_attributes.SENTRY_LINK_TYPE]: "message_origin" }
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4111
|
+
return new SentryBullMQSpan(span, (0, _sentry_core.getCurrentScope)());
|
|
4112
|
+
}
|
|
4113
|
+
};
|
|
4114
|
+
// src/integrations/bullmq/index.ts
|
|
4115
|
+
/**
|
|
4116
|
+
* A Sentry-specific telemetry implementation for BullMQ.
|
|
4117
|
+
*
|
|
4118
|
+
* This implements BullMQ's Telemetry interface to provide automatic tracing
|
|
4119
|
+
* for queue operations with proper Queue Insights attributes.
|
|
4120
|
+
*
|
|
4121
|
+
* @example
|
|
4122
|
+
* ```javascript
|
|
4123
|
+
* import * as Sentry from '@sentry/node';
|
|
4124
|
+
* import { Queue, Worker } from 'bullmq';
|
|
4125
|
+
*
|
|
4126
|
+
* const telemetry = new Sentry.BullMQTelemetry();
|
|
4127
|
+
*
|
|
4128
|
+
* const queue = new Queue('myQueue', {
|
|
4129
|
+
* connection: { host: '127.0.0.1', port: 6379 },
|
|
4130
|
+
* telemetry,
|
|
4131
|
+
* });
|
|
4132
|
+
*
|
|
4133
|
+
* const worker = new Worker('myQueue', async (job) => {
|
|
4134
|
+
* // Process job
|
|
4135
|
+
* }, {
|
|
4136
|
+
* connection: { host: '127.0.0.1', port: 6379 },
|
|
4137
|
+
* telemetry,
|
|
4138
|
+
* });
|
|
4139
|
+
* ```
|
|
4140
|
+
*
|
|
4141
|
+
* To also send BullMQ's job metrics to Sentry, use `new Sentry.BullMQTelemetry({ enableMetrics: true })`.
|
|
4142
|
+
*
|
|
4143
|
+
* @see https://docs.bullmq.io/guide/telemetry
|
|
4144
|
+
*/
|
|
4145
|
+
var BullMQTelemetry = class {
|
|
4146
|
+
constructor(options = {}) {
|
|
4147
|
+
this.tracer = new SentryBullMQTracer();
|
|
4148
|
+
this.contextManager = new SentryBullMQContextManager();
|
|
4149
|
+
if (options.enableMetrics) this.meter = new SentryBullMQMeter();
|
|
4150
|
+
}
|
|
4151
|
+
};
|
|
3514
4152
|
// src/integrations/google-genai.ts
|
|
3515
4153
|
const INTEGRATION_NAME$24 = "Google_GenAI";
|
|
3516
4154
|
const ORIGIN$20 = "auto.ai.google_genai";
|
|
@@ -3526,6 +4164,10 @@ const INSTRUMENTED_CHANNELS$2 = [
|
|
|
3526
4164
|
{
|
|
3527
4165
|
channel: CHANNELS.GOOGLE_GENAI_CHAT,
|
|
3528
4166
|
operation: "chat"
|
|
4167
|
+
},
|
|
4168
|
+
{
|
|
4169
|
+
channel: CHANNELS.GOOGLE_GENAI_DECIDE,
|
|
4170
|
+
operation: "decide"
|
|
3529
4171
|
}
|
|
3530
4172
|
];
|
|
3531
4173
|
const _googleGenAIIntegration = ((options = {}) => {
|
|
@@ -3541,11 +4183,12 @@ function instrumentGoogleGenai(options) {
|
|
|
3541
4183
|
beforeSpanEnd: (span, data) => {
|
|
3542
4184
|
if ("error" in data) {
|
|
3543
4185
|
const params = require_exports.resolveChatParams(operation, data.arguments?.[0], data.self);
|
|
3544
|
-
require_exports.markCancelledIfAborted(span, require_exports.
|
|
4186
|
+
require_exports.markCancelledIfAborted(span, require_exports.getCallAbortSignal(operation, params, data.arguments?.[1]));
|
|
3545
4187
|
}
|
|
3546
|
-
if (operation !== "embeddings") require_exports.addResponseAttributes$2(span, data.result,
|
|
4188
|
+
if (operation !== "embeddings") require_exports.addResponseAttributes$2(span, data.result, !!data._sentryRecordOutputs, operation);
|
|
4189
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
3547
4190
|
},
|
|
3548
|
-
deferSpanEnd: ({ span, data }) => wrapStreamResult$2(span, data, operation
|
|
4191
|
+
deferSpanEnd: ({ span, data }) => wrapStreamResult$2(span, data, operation)
|
|
3549
4192
|
});
|
|
3550
4193
|
}
|
|
3551
4194
|
/**
|
|
@@ -3561,9 +4204,14 @@ function createGenAiSpan$3(data, operation, options) {
|
|
|
3561
4204
|
if (origin === ORIGIN$20 && op === "gen_ai.chat") return;
|
|
3562
4205
|
}
|
|
3563
4206
|
}
|
|
3564
|
-
const
|
|
3565
|
-
const params = require_exports.resolveChatParams(operation,
|
|
3566
|
-
const
|
|
4207
|
+
const request = (data.arguments ?? [])[0];
|
|
4208
|
+
const params = require_exports.resolveChatParams(operation, request, data.self);
|
|
4209
|
+
const call = {
|
|
4210
|
+
operation,
|
|
4211
|
+
request
|
|
4212
|
+
};
|
|
4213
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, call);
|
|
4214
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
3567
4215
|
const attributes = require_exports.extractRequestAttributes$1(operation, params, data.self, recordInputs);
|
|
3568
4216
|
const model = attributes[_sentry_conventions_attributes.GEN_AI_REQUEST_MODEL] || "unknown";
|
|
3569
4217
|
attributes[_sentry_conventions_attributes.SENTRY_ORIGIN] = ORIGIN$20;
|
|
@@ -3574,6 +4222,8 @@ function createGenAiSpan$3(data, operation, options) {
|
|
|
3574
4222
|
attributes
|
|
3575
4223
|
});
|
|
3576
4224
|
if (recordInputs && params) require_exports.addPrivateRequestAttributes(span, params, operation);
|
|
4225
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
4226
|
+
data._sentryOnSpanEnd = (result) => require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
3577
4227
|
return span;
|
|
3578
4228
|
}
|
|
3579
4229
|
function isAsyncIterable$2(value) {
|
|
@@ -3584,22 +4234,21 @@ function isAsyncIterable$2(value) {
|
|
|
3584
4234
|
* For a stream we patch `result[Symbol.asyncIterator]` in place so `instrumentStream` ends the
|
|
3585
4235
|
* span when iteration finishes.
|
|
3586
4236
|
*/
|
|
3587
|
-
function wrapStreamResult$2(span, data, operation
|
|
4237
|
+
function wrapStreamResult$2(span, data, operation) {
|
|
3588
4238
|
const result = data.result;
|
|
3589
4239
|
if (!isAsyncIterable$2(result)) return false;
|
|
3590
|
-
const { recordOutputs } = require_exports.resolveAIRecordingOptions(options);
|
|
3591
4240
|
const iterate = result[Symbol.asyncIterator].bind(result);
|
|
3592
4241
|
const params = require_exports.resolveChatParams(operation, data.arguments?.[0], data.self);
|
|
3593
|
-
const instrumented = require_exports.instrumentStream({ [Symbol.asyncIterator]: iterate }, span,
|
|
4242
|
+
const instrumented = require_exports.instrumentStream({ [Symbol.asyncIterator]: iterate }, span, !!data._sentryRecordOutputs, require_exports.getAbortSignal(params), data._sentryOnSpanEnd);
|
|
3594
4243
|
result[Symbol.asyncIterator] = () => instrumented;
|
|
3595
4244
|
return true;
|
|
3596
4245
|
}
|
|
3597
4246
|
/**
|
|
3598
4247
|
* Diagnostics-channel-based Google GenAI integration. Subscribes to the
|
|
3599
4248
|
* `orchestrion:@google/genai:*` diagnostics_channels injected into the SDK's `Models`
|
|
3600
|
-
* (`generateContent`/`generateContentStream`/`embedContent`)
|
|
3601
|
-
* (`sendMessage`/`sendMessageStream`) methods, so it requires the Sentry
|
|
3602
|
-
* bundler plugin.
|
|
4249
|
+
* (`generateContent`/`generateContentStream`/`embedContent`), `Chat`
|
|
4250
|
+
* (`sendMessage`/`sendMessageStream`) and decisions (`create`) methods, so it requires the Sentry
|
|
4251
|
+
* runtime hook or bundler plugin.
|
|
3603
4252
|
*/
|
|
3604
4253
|
const googleGenAIIntegration = (0, _sentry_core.defineIntegration)(_googleGenAIIntegration);
|
|
3605
4254
|
// src/integrations/graphql/constants.ts
|
|
@@ -4767,7 +5416,7 @@ function instrumentIoredis(options) {
|
|
|
4767
5416
|
const INTEGRATION_NAME$19 = "Redis";
|
|
4768
5417
|
const ORIGIN$15 = "auto.db.redis";
|
|
4769
5418
|
const DB_SYSTEM_VALUE_REDIS = "redis";
|
|
4770
|
-
function endSpan(span, err) {
|
|
5419
|
+
function endSpan$1(span, err) {
|
|
4771
5420
|
if (err) span.setStatus({
|
|
4772
5421
|
code: _sentry_core.SPAN_STATUS_ERROR,
|
|
4773
5422
|
message: err instanceof Error ? err.message : String(err)
|
|
@@ -4834,14 +5483,14 @@ function subscribeLegacyRedisCommand(cacheOptions) {
|
|
|
4834
5483
|
const parentSpan = (0, _sentry_core.getActiveSpan)();
|
|
4835
5484
|
command.callback = function(err, reply) {
|
|
4836
5485
|
if (!err) applyCacheResponseAttributes(span, reply);
|
|
4837
|
-
endSpan(span, err);
|
|
5486
|
+
endSpan$1(span, err);
|
|
4838
5487
|
const args = arguments;
|
|
4839
5488
|
return (0, _sentry_core.withActiveSpan)(parentSpan ?? null, () => originalCallback.apply(this, args));
|
|
4840
5489
|
};
|
|
4841
5490
|
},
|
|
4842
5491
|
error(data) {
|
|
4843
5492
|
const span = data._sentrySpan;
|
|
4844
|
-
if (span) endSpan(span, data.error);
|
|
5493
|
+
if (span) endSpan$1(span, data.error);
|
|
4845
5494
|
}
|
|
4846
5495
|
});
|
|
4847
5496
|
}
|
|
@@ -5353,12 +6002,13 @@ function createOpenAiCompatibleIntegration(provider) {
|
|
|
5353
6002
|
for (const { channel, operation } of instrumentedChannels) bindTracingChannelToSpan(tracingChannel(channel), (data) => createGenAiSpan$2(data, operation, provider, options), {
|
|
5354
6003
|
beforeSpanEnd: (span, data) => {
|
|
5355
6004
|
if ("error" in data) require_exports.markCancelledIfAborted(span, require_exports.getRequestSignal(data.arguments?.[1]));
|
|
5356
|
-
require_exports.addResponseAttributes$4(span, data.result,
|
|
6005
|
+
require_exports.addResponseAttributes$4(span, data.result, !!data._sentryRecordOutputs);
|
|
6006
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
5357
6007
|
},
|
|
5358
6008
|
deferSpanEnd: ({ span, data, end }) => wrapApiPromiseResponse(data.result, (response) => {
|
|
5359
6009
|
data.result = response;
|
|
5360
|
-
if (!wrapStreamResult$1(span, data
|
|
5361
|
-
}, end) || wrapStreamResult$1(span, data
|
|
6010
|
+
if (!wrapStreamResult$1(span, data)) end();
|
|
6011
|
+
}, end) || wrapStreamResult$1(span, data)
|
|
5362
6012
|
});
|
|
5363
6013
|
}
|
|
5364
6014
|
return ((options = {}) => {
|
|
@@ -5378,7 +6028,12 @@ function createGenAiSpan$2(data, operation, provider, options) {
|
|
|
5378
6028
|
if ((0, _sentry_core._INTERNAL_shouldSkipAiProviderWrapping)(provider.integrationName)) return;
|
|
5379
6029
|
const args = data.arguments ?? [];
|
|
5380
6030
|
const params = args[0];
|
|
5381
|
-
const
|
|
6031
|
+
const call = {
|
|
6032
|
+
operation,
|
|
6033
|
+
request: params
|
|
6034
|
+
};
|
|
6035
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, call);
|
|
6036
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
5382
6037
|
const attributes = require_exports.extractRequestAttributes$3(args, operation, recordInputs);
|
|
5383
6038
|
attributes[_sentry_conventions_attributes.GEN_AI_PROVIDER_NAME] = provider.providerName;
|
|
5384
6039
|
attributes[_sentry_conventions_attributes.SENTRY_ORIGIN] = provider.origin;
|
|
@@ -5390,6 +6045,8 @@ function createGenAiSpan$2(data, operation, provider, options) {
|
|
|
5390
6045
|
attributes
|
|
5391
6046
|
});
|
|
5392
6047
|
if (recordInputs && params) require_exports.addRequestAttributes$1(span, params, operation);
|
|
6048
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
6049
|
+
data._sentryOnSpanEnd = (result) => require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
5393
6050
|
return span;
|
|
5394
6051
|
}
|
|
5395
6052
|
function isAsyncIterable$1(value) {
|
|
@@ -5404,12 +6061,11 @@ function isAsyncIterable$1(value) {
|
|
|
5404
6061
|
* to hand span-ending ownership to `instrumentStream`; `false` for non-streaming/errored results, which end
|
|
5405
6062
|
* via the normal `beforeSpanEnd` path.
|
|
5406
6063
|
*/
|
|
5407
|
-
function wrapStreamResult$1(span, data
|
|
6064
|
+
function wrapStreamResult$1(span, data) {
|
|
5408
6065
|
const result = data.result;
|
|
5409
6066
|
if (!isAsyncIterable$1(result)) return false;
|
|
5410
|
-
const { recordOutputs } = require_exports.resolveAIRecordingOptions(options);
|
|
5411
6067
|
const iterate = result[Symbol.asyncIterator].bind(result);
|
|
5412
|
-
const instrumented = require_exports.instrumentStream$1({ [Symbol.asyncIterator]: iterate }, span,
|
|
6068
|
+
const instrumented = require_exports.instrumentStream$1({ [Symbol.asyncIterator]: iterate }, span, !!data._sentryRecordOutputs, data._sentryOnSpanEnd);
|
|
5413
6069
|
result[Symbol.asyncIterator] = () => instrumented;
|
|
5414
6070
|
return true;
|
|
5415
6071
|
}
|
|
@@ -5504,12 +6160,11 @@ const _langGraphIntegration = ((options = {}) => {
|
|
|
5504
6160
|
};
|
|
5505
6161
|
});
|
|
5506
6162
|
function instrumentLanggraph(options) {
|
|
5507
|
-
const
|
|
5508
|
-
const sentryHandler = require_exports.createLangChainCallbackHandler(resolvedOptions);
|
|
6163
|
+
const sentryHandler = require_exports.createLangChainCallbackHandler(require_exports.getBooleanRecordingOptions(options));
|
|
5509
6164
|
tracingChannel(CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE).end.subscribe((message) => {
|
|
5510
6165
|
if (insideCreateReactAgent || require_exports.isInsideManualLangGraphInstrumentation()) return;
|
|
5511
6166
|
const { arguments: args, result } = message;
|
|
5512
|
-
require_exports.instrumentCompiledGraph(result, getFirstArgObject(args) ?? {},
|
|
6167
|
+
require_exports.instrumentCompiledGraph(result, getFirstArgObject(args) ?? {}, options, null, sentryHandler);
|
|
5513
6168
|
});
|
|
5514
6169
|
const reactAgentChannel = tracingChannel(CHANNELS.LANGGRAPH_CREATE_REACT_AGENT);
|
|
5515
6170
|
reactAgentChannel.start.subscribe((message) => {
|
|
@@ -5517,7 +6172,7 @@ function instrumentLanggraph(options) {
|
|
|
5517
6172
|
try {
|
|
5518
6173
|
const { arguments: args } = message;
|
|
5519
6174
|
const params = getFirstArgObject(args);
|
|
5520
|
-
if (params && Array.isArray(params.tools) && params.tools.length > 0) require_exports.wrapToolsWithSpans(params.tools,
|
|
6175
|
+
if (params && Array.isArray(params.tools) && params.tools.length > 0) require_exports.wrapToolsWithSpans(params.tools, options, require_exports.extractAgentNameFromParams(args) ?? void 0);
|
|
5521
6176
|
} catch (error) {
|
|
5522
6177
|
require_debug_build.DEBUG_BUILD && _sentry_core.debug.error("[instrumentation:langgraph] failed to wrap createReactAgent tools", error);
|
|
5523
6178
|
}
|
|
@@ -5527,7 +6182,7 @@ function instrumentLanggraph(options) {
|
|
|
5527
6182
|
if (require_exports.isInsideManualLangGraphInstrumentation()) return;
|
|
5528
6183
|
const { arguments: args, result } = message;
|
|
5529
6184
|
const agentName = require_exports.extractAgentNameFromParams(args) ?? void 0;
|
|
5530
|
-
require_exports.instrumentCompiledGraph(result, agentName ? { name: agentName } : {},
|
|
6185
|
+
require_exports.instrumentCompiledGraph(result, agentName ? { name: agentName } : {}, options, require_exports.extractLLMFromParams(args), sentryHandler);
|
|
5531
6186
|
});
|
|
5532
6187
|
reactAgentChannel.error.subscribe(() => {
|
|
5533
6188
|
insideCreateReactAgent = false;
|
|
@@ -5684,6 +6339,22 @@ function getRequestContentAttributes(context) {
|
|
|
5684
6339
|
[_sentry_conventions_attributes.GEN_AI_TOOL_DEFINITIONS]: tools.length ? (0, _sentry_core.stringify)(tools) : void 0
|
|
5685
6340
|
};
|
|
5686
6341
|
}
|
|
6342
|
+
/**
|
|
6343
|
+
* Records `gen_ai.response.time_to_first_chunk` for a streamed request. The stream has one consumer,
|
|
6344
|
+
* so instead of reading it, this wraps `push`, which the provider calls for each event as it decodes
|
|
6345
|
+
* it. The wrapper is removed after the first chunk.
|
|
6346
|
+
*/
|
|
6347
|
+
function observePiAiFirstChunk(span, events) {
|
|
6348
|
+
const push = events?.push;
|
|
6349
|
+
if (!events || typeof push !== "function") return;
|
|
6350
|
+
events.push = function(event) {
|
|
6351
|
+
if (event?.type !== "start") {
|
|
6352
|
+
require_exports.recordTimeToFirstChunk(span);
|
|
6353
|
+
events.push = push;
|
|
6354
|
+
}
|
|
6355
|
+
return push.call(this, event);
|
|
6356
|
+
};
|
|
6357
|
+
}
|
|
5687
6358
|
// src/integrations/pi-ai.ts
|
|
5688
6359
|
const _piAiIntegration = ((options = {}) => {
|
|
5689
6360
|
return {
|
|
@@ -5699,32 +6370,52 @@ function instrumentPiAi(options) {
|
|
|
5699
6370
|
const startSpan = (data, streaming) => {
|
|
5700
6371
|
if (require_exports.isInsidePiAiSpan()) return;
|
|
5701
6372
|
const [model, context, callOptions] = data.arguments ?? [];
|
|
5702
|
-
const
|
|
6373
|
+
const call = {
|
|
6374
|
+
model,
|
|
6375
|
+
context,
|
|
6376
|
+
options: callOptions
|
|
6377
|
+
};
|
|
6378
|
+
const driver = require_exports.getPiAiDriver();
|
|
6379
|
+
const { recordInputs, recordOutputs } = require_exports.resolvePiAiRecordingOptions(options, call, driver);
|
|
5703
6380
|
data._sentryRecordOutputs = recordOutputs;
|
|
5704
|
-
|
|
6381
|
+
const span = (0, _sentry_core.startInactiveSpan)(getPiAiChatSpanOptions({
|
|
5705
6382
|
model: model ?? {},
|
|
5706
6383
|
context,
|
|
5707
6384
|
callOptions,
|
|
5708
6385
|
streaming,
|
|
5709
6386
|
recordInputs
|
|
5710
6387
|
}));
|
|
6388
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
6389
|
+
driver?.onSpanStart(span);
|
|
6390
|
+
data._sentryOnSpanEnd = (result) => {
|
|
6391
|
+
require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
6392
|
+
driver?.onSpanEnd(span, result);
|
|
6393
|
+
};
|
|
6394
|
+
return span;
|
|
5711
6395
|
};
|
|
5712
|
-
const
|
|
6396
|
+
const beforeSpanEnd = (span, data, message) => {
|
|
6397
|
+
if ("error" in data) {
|
|
6398
|
+
data._sentryOnSpanEnd?.({ error: data.error });
|
|
6399
|
+
return;
|
|
6400
|
+
}
|
|
5713
6401
|
if (message && typeof message === "object") setPiAiResponseAttributes(span, message, !!data._sentryRecordOutputs);
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
6402
|
+
data._sentryOnSpanEnd?.({ response: message });
|
|
6403
|
+
};
|
|
6404
|
+
bindTracingChannelToSpan(streamChannel, (data) => startSpan(data, true), {
|
|
6405
|
+
deferSpanEnd: ({ span, data, end }) => {
|
|
6406
|
+
const events = data.result;
|
|
6407
|
+
const settled = "error" in data || typeof events?.result !== "function" ? void 0 : events.result();
|
|
6408
|
+
if (!(0, _sentry_core.isThenable)(settled)) return false;
|
|
6409
|
+
observePiAiFirstChunk(span, events);
|
|
6410
|
+
settled.then((message) => {
|
|
6411
|
+
data._sentryMessage = message;
|
|
6412
|
+
end();
|
|
6413
|
+
}, end);
|
|
6414
|
+
return true;
|
|
6415
|
+
},
|
|
6416
|
+
beforeSpanEnd: (span, data) => beforeSpanEnd(span, data, data._sentryMessage)
|
|
6417
|
+
});
|
|
6418
|
+
bindTracingChannelToSpan(completeChannel, (data) => startSpan(data, false), { beforeSpanEnd: (span, data) => beforeSpanEnd(span, data, data.result) });
|
|
5728
6419
|
}
|
|
5729
6420
|
/**
|
|
5730
6421
|
* Traces the requests sent with pi-ai (`@earendil-works/pi-ai` >= 0.80.0 < 2) as `gen_ai.chat` spans,
|
|
@@ -5945,7 +6636,14 @@ function instrumentToolPhase(runtime, runs, wrapTool) {
|
|
|
5945
6636
|
/** Wrap a tool so each call gets a `gen_ai.execute_tool` span. */
|
|
5946
6637
|
function instrumentTool(tool, runs, options) {
|
|
5947
6638
|
const execute = (args, api, context) => {
|
|
5948
|
-
const
|
|
6639
|
+
const toolCall = {
|
|
6640
|
+
operation: "execute_tool",
|
|
6641
|
+
tool,
|
|
6642
|
+
args,
|
|
6643
|
+
api,
|
|
6644
|
+
context
|
|
6645
|
+
};
|
|
6646
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, toolCall);
|
|
5949
6647
|
const phaseCalls = runs.toolCalls.get(api?.taskId);
|
|
5950
6648
|
const calls = phaseCalls?.some((call) => call.callId !== void 0 && call.callId === api?.callId) ? void 0 : phaseCalls;
|
|
5951
6649
|
return (0, _sentry_core.startSpanManual)({
|
|
@@ -5967,9 +6665,11 @@ function instrumentTool(tool, runs, options) {
|
|
|
5967
6665
|
recordOutputs
|
|
5968
6666
|
};
|
|
5969
6667
|
calls?.push(call);
|
|
6668
|
+
require_exports.runGenAiSpanStart(options, span, toolCall);
|
|
5970
6669
|
try {
|
|
5971
6670
|
const result = await tool.execute(args, trackOwnedConversations(api, span, runs), context);
|
|
5972
6671
|
call.endTimestamp = (0, _sentry_core.timestampInSeconds)();
|
|
6672
|
+
call.onSpanEnd = () => require_exports.runGenAiSpanEnd(options, span, toolCall, { response: result });
|
|
5973
6673
|
if (!calls) finishToolCall(call, {
|
|
5974
6674
|
content: result?.output ?? result?.content,
|
|
5975
6675
|
isError: result?.isError
|
|
@@ -5978,6 +6678,7 @@ function instrumentTool(tool, runs, options) {
|
|
|
5978
6678
|
} catch (error) {
|
|
5979
6679
|
call.endTimestamp = (0, _sentry_core.timestampInSeconds)();
|
|
5980
6680
|
call.failed = true;
|
|
6681
|
+
call.onSpanEnd = () => require_exports.runGenAiSpanEnd(options, span, toolCall, { error });
|
|
5981
6682
|
if (context?.abortSignal?.aborted) span.setStatus({
|
|
5982
6683
|
code: _sentry_core.SPAN_STATUS_ERROR,
|
|
5983
6684
|
message: "cancelled"
|
|
@@ -5992,7 +6693,10 @@ function instrumentTool(tool, runs, options) {
|
|
|
5992
6693
|
type: PI_DURABLE_ORIGIN
|
|
5993
6694
|
} });
|
|
5994
6695
|
}
|
|
5995
|
-
if (!calls)
|
|
6696
|
+
if (!calls) {
|
|
6697
|
+
call.onSpanEnd();
|
|
6698
|
+
span.end(call.endTimestamp);
|
|
6699
|
+
}
|
|
5996
6700
|
throw error;
|
|
5997
6701
|
}
|
|
5998
6702
|
});
|
|
@@ -6010,6 +6714,7 @@ function finishToolCall(call, message) {
|
|
|
6010
6714
|
message: "internal_error"
|
|
6011
6715
|
});
|
|
6012
6716
|
}
|
|
6717
|
+
call.onSpanEnd?.();
|
|
6013
6718
|
call.span.end(call.endTimestamp);
|
|
6014
6719
|
}
|
|
6015
6720
|
function observeToolResultEntries(tx, committed) {
|
|
@@ -6113,6 +6818,7 @@ function endRunsOnClose(harnessOptions, harness) {
|
|
|
6113
6818
|
code: _sentry_core.SPAN_STATUS_ERROR,
|
|
6114
6819
|
message: "cancelled"
|
|
6115
6820
|
});
|
|
6821
|
+
call.onSpanEnd?.();
|
|
6116
6822
|
call.span.end(call.endTimestamp);
|
|
6117
6823
|
}
|
|
6118
6824
|
runs.toolCalls.clear();
|
|
@@ -6190,7 +6896,11 @@ function runPhase(kind, phase, runtime, context, runs, wrapTool, isAbort, option
|
|
|
6190
6896
|
}
|
|
6191
6897
|
}
|
|
6192
6898
|
scope.setConversationId(sessionId ?? toSentryConversationId(runs, conversationId));
|
|
6193
|
-
require_exports.
|
|
6899
|
+
require_exports.setPiAiDriverOptions(scope, options, {
|
|
6900
|
+
operation: "chat",
|
|
6901
|
+
runtime,
|
|
6902
|
+
context
|
|
6903
|
+
});
|
|
6194
6904
|
try {
|
|
6195
6905
|
return await phase(observed);
|
|
6196
6906
|
} catch (error) {
|
|
@@ -6292,7 +7002,7 @@ function finishClassifierEvaluation(call, message) {
|
|
|
6292
7002
|
});
|
|
6293
7003
|
if ((0, _sentry_core.isObjectLike)(data?.input)) span.setAttribute(_sentry_conventions_attributes.GEN_AI_INPUT_MESSAGES, require_exports.getEvaluationInputMessages(data.input));
|
|
6294
7004
|
if (data?.output !== void 0) span.setAttribute(_sentry_conventions_attributes.GEN_AI_OUTPUT_MESSAGES, require_exports.getEvaluationOutputMessages(data.output));
|
|
6295
|
-
|
|
7005
|
+
call.end?.();
|
|
6296
7006
|
}
|
|
6297
7007
|
// src/integrations/mastra.ts
|
|
6298
7008
|
/** Mastra AISpan → the id the exporter keys its Sentry span on. */
|
|
@@ -7116,9 +7826,11 @@ const _mistralAIIntegration = ((options = {}) => {
|
|
|
7116
7826
|
function instrumentMistral(options) {
|
|
7117
7827
|
for (const { channel, operation, streaming } of INSTRUMENTED_CHANNELS$1) bindTracingChannelToSpan(tracingChannel(channel), (data) => createGenAiSpan$1(data, operation, streaming, options), {
|
|
7118
7828
|
beforeSpanEnd: (span, data) => {
|
|
7119
|
-
require_exports.
|
|
7829
|
+
if ("error" in data) require_exports.markCancelledIfAborted(span, require_exports.getMistralRequestSignal(data.arguments?.[1]));
|
|
7830
|
+
require_exports.addResponseAttributes$1(span, data.result, !!data._sentryRecordOutputs);
|
|
7831
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
7120
7832
|
},
|
|
7121
|
-
deferSpanEnd: ({ span, data }) => streaming && require_exports.instrumentEventStream(data.result, span, require_exports.
|
|
7833
|
+
deferSpanEnd: ({ span, data }) => streaming && require_exports.instrumentEventStream(data.result, span, !!data._sentryRecordOutputs, require_exports.getMistralRequestSignal(data.arguments?.[1]), data._sentryOnSpanEnd)
|
|
7122
7834
|
});
|
|
7123
7835
|
}
|
|
7124
7836
|
/**
|
|
@@ -7129,7 +7841,12 @@ function createGenAiSpan$1(data, operation, streaming, options) {
|
|
|
7129
7841
|
if (require_exports.shouldSkipAiProviderSpan(INTEGRATION_NAME$10)) return;
|
|
7130
7842
|
const args = data.arguments ?? [];
|
|
7131
7843
|
const params = args[0];
|
|
7132
|
-
const
|
|
7844
|
+
const call = {
|
|
7845
|
+
operation,
|
|
7846
|
+
request: params
|
|
7847
|
+
};
|
|
7848
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, call);
|
|
7849
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
7133
7850
|
const attributes = require_exports.extractRequestAttributes(args, operation, recordInputs, streaming);
|
|
7134
7851
|
attributes[_sentry_conventions_attributes.SENTRY_ORIGIN] = require_exports.MISTRAL_ORIGIN;
|
|
7135
7852
|
const span = (0, _sentry_core.startInactiveSpan)({
|
|
@@ -7138,6 +7855,8 @@ function createGenAiSpan$1(data, operation, streaming, options) {
|
|
|
7138
7855
|
attributes
|
|
7139
7856
|
});
|
|
7140
7857
|
if (recordInputs && params) require_exports.addRequestAttributes(span, params, operation);
|
|
7858
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
7859
|
+
data._sentryOnSpanEnd = (result) => require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
7141
7860
|
return span;
|
|
7142
7861
|
}
|
|
7143
7862
|
/**
|
|
@@ -7170,9 +7889,22 @@ const _typesafeIntegration = ((options = {}) => {
|
|
|
7170
7889
|
};
|
|
7171
7890
|
});
|
|
7172
7891
|
function instrumentTypeSafe(options) {
|
|
7173
|
-
bindTracingChannelToSpan(tracingChannel(CHANNELS.TYPESAFE_SYSTEM_ONE), (data) =>
|
|
7892
|
+
bindTracingChannelToSpan(tracingChannel(CHANNELS.TYPESAFE_SYSTEM_ONE), (data) => {
|
|
7893
|
+
const request = data.arguments?.[0];
|
|
7894
|
+
const call = { request };
|
|
7895
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, call);
|
|
7896
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
7897
|
+
const span = require_exports.startDecideSpan(request, data.self, recordInputs);
|
|
7898
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
7899
|
+
data._sentryOnSpanEnd = (result) => require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
7900
|
+
return span;
|
|
7901
|
+
}, {
|
|
7174
7902
|
beforeSpanEnd: (span, data) => {
|
|
7175
|
-
if (
|
|
7903
|
+
if ("error" in data) data._sentryOnSpanEnd?.({ error: data.error });
|
|
7904
|
+
else {
|
|
7905
|
+
require_exports.addResponseAttributes(span, data.result, !!data._sentryRecordOutputs);
|
|
7906
|
+
data._sentryOnSpanEnd?.({ response: data.result });
|
|
7907
|
+
}
|
|
7176
7908
|
},
|
|
7177
7909
|
deferSpanEnd: ({ data, end }) => require_exports.onSystemOneResponse(data.result, (body) => {
|
|
7178
7910
|
data.result = body;
|
|
@@ -7410,6 +8142,215 @@ const _mysql2Integration = (() => {
|
|
|
7410
8142
|
* (the common case) are fully instrumented.
|
|
7411
8143
|
*/
|
|
7412
8144
|
const mysql2Integration = (0, _sentry_core.defineIntegration)(_mysql2Integration);
|
|
8145
|
+
// src/integrations/pino.ts
|
|
8146
|
+
const SENTRY_TRACK_SYMBOL = Symbol("sentry-track-pino-logger");
|
|
8147
|
+
/**
|
|
8148
|
+
* Gets a custom Pino key from a logger instance by searching for the symbol.
|
|
8149
|
+
* Pino uses non-global symbols like Symbol('pino.messageKey'): https://github.com/pinojs/pino/blob/8a816c0b1f72de5ae9181f3bb402109b66f7d812/lib/symbols.js
|
|
8150
|
+
*/
|
|
8151
|
+
function getPinoKey(logger, symbolName, defaultKey) {
|
|
8152
|
+
const symbols = Object.getOwnPropertySymbols(logger);
|
|
8153
|
+
const symbolString = `Symbol(${symbolName})`;
|
|
8154
|
+
for (const sym of symbols) if (sym.toString() === symbolString) {
|
|
8155
|
+
const value = logger[sym];
|
|
8156
|
+
return typeof value === "string" ? value : defaultKey;
|
|
8157
|
+
}
|
|
8158
|
+
return defaultKey;
|
|
8159
|
+
}
|
|
8160
|
+
const DEFAULT_OPTIONS = {
|
|
8161
|
+
autoInstrument: true,
|
|
8162
|
+
error: {
|
|
8163
|
+
levels: [],
|
|
8164
|
+
handled: true
|
|
8165
|
+
},
|
|
8166
|
+
log: { levels: [
|
|
8167
|
+
"trace",
|
|
8168
|
+
"debug",
|
|
8169
|
+
"info",
|
|
8170
|
+
"warn",
|
|
8171
|
+
"error",
|
|
8172
|
+
"fatal"
|
|
8173
|
+
] }
|
|
8174
|
+
};
|
|
8175
|
+
function stripIgnoredFields(result) {
|
|
8176
|
+
const { level, time, pid, hostname, ...rest } = result;
|
|
8177
|
+
return rest;
|
|
8178
|
+
}
|
|
8179
|
+
const _pinoIntegration = (0, _sentry_core.defineIntegration)((userOptions = {}) => {
|
|
8180
|
+
const options = {
|
|
8181
|
+
autoInstrument: userOptions.autoInstrument !== false,
|
|
8182
|
+
error: {
|
|
8183
|
+
...DEFAULT_OPTIONS.error,
|
|
8184
|
+
...userOptions.error
|
|
8185
|
+
},
|
|
8186
|
+
log: {
|
|
8187
|
+
...DEFAULT_OPTIONS.log,
|
|
8188
|
+
...userOptions.log
|
|
8189
|
+
}
|
|
8190
|
+
};
|
|
8191
|
+
function shouldTrackLogger(logger) {
|
|
8192
|
+
const override = logger[SENTRY_TRACK_SYMBOL];
|
|
8193
|
+
return override === "track" || override !== "ignore" && options.autoInstrument;
|
|
8194
|
+
}
|
|
8195
|
+
return {
|
|
8196
|
+
name: "Pino",
|
|
8197
|
+
setup: () => {
|
|
8198
|
+
const integratedChannel = tracingChannel("pino_asJson");
|
|
8199
|
+
function onPinoStart(self, args, result) {
|
|
8200
|
+
if (!shouldTrackLogger(self)) return;
|
|
8201
|
+
const resultObj = stripIgnoredFields(result);
|
|
8202
|
+
const [captureObj, message, levelNumber] = args;
|
|
8203
|
+
const level = self?.levels?.labels?.[levelNumber] || "info";
|
|
8204
|
+
const messageKey = getPinoKey(self, "pino.messageKey", "msg");
|
|
8205
|
+
const logMessage = message || resultObj?.[messageKey] || "";
|
|
8206
|
+
if (options.log.levels.includes(level)) {
|
|
8207
|
+
const attributes = {
|
|
8208
|
+
...resultObj,
|
|
8209
|
+
[_sentry_conventions_attributes.SENTRY_ORIGIN]: "auto.log.pino",
|
|
8210
|
+
"pino.logger.level": levelNumber
|
|
8211
|
+
};
|
|
8212
|
+
(0, _sentry_core._INTERNAL_captureLog)({
|
|
8213
|
+
level,
|
|
8214
|
+
message: logMessage,
|
|
8215
|
+
attributes
|
|
8216
|
+
});
|
|
8217
|
+
}
|
|
8218
|
+
if (options.error.levels.includes(level)) {
|
|
8219
|
+
const errorKey = getPinoKey(self, "pino.errorKey", "err");
|
|
8220
|
+
const pinoContext = {};
|
|
8221
|
+
for (const [key, value] of Object.entries(resultObj)) if (key !== errorKey && key !== messageKey) pinoContext[key] = value;
|
|
8222
|
+
if (logMessage) pinoContext[messageKey] = logMessage;
|
|
8223
|
+
const captureContext = {
|
|
8224
|
+
level: (0, _sentry_core.severityLevelFromString)(level),
|
|
8225
|
+
contexts: { pino: pinoContext }
|
|
8226
|
+
};
|
|
8227
|
+
(0, _sentry_core.withScope)((scope) => {
|
|
8228
|
+
scope.addEventProcessor((event) => {
|
|
8229
|
+
event.logger = "pino";
|
|
8230
|
+
(0, _sentry_core.addExceptionMechanism)(event, {
|
|
8231
|
+
handled: options.error.handled,
|
|
8232
|
+
type: "auto.log.pino"
|
|
8233
|
+
});
|
|
8234
|
+
return event;
|
|
8235
|
+
});
|
|
8236
|
+
const error = captureObj[errorKey];
|
|
8237
|
+
if (error) {
|
|
8238
|
+
(0, _sentry_core.captureException)(error, captureContext);
|
|
8239
|
+
return;
|
|
8240
|
+
}
|
|
8241
|
+
(0, _sentry_core.captureMessage)(logMessage, captureContext);
|
|
8242
|
+
});
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8245
|
+
integratedChannel.end.subscribe((data) => {
|
|
8246
|
+
const { instance, arguments: args, result } = data;
|
|
8247
|
+
onPinoStart(instance, args, JSON.parse(result));
|
|
8248
|
+
});
|
|
8249
|
+
}
|
|
8250
|
+
};
|
|
8251
|
+
});
|
|
8252
|
+
/**
|
|
8253
|
+
* Integration for Pino logging library.
|
|
8254
|
+
* Captures Pino logs as Sentry logs and optionally captures some log levels as events.
|
|
8255
|
+
*
|
|
8256
|
+
* By default, all Pino loggers will be captured. To ignore a specific logger, use `pinoIntegration.untrackLogger(logger)`.
|
|
8257
|
+
*
|
|
8258
|
+
* If you disable automatic instrumentation with `autoInstrument: false`, you can mark specific loggers to be tracked with `pinoIntegration.trackLogger(logger)`.
|
|
8259
|
+
*
|
|
8260
|
+
* Requires Pino >=v8.0.0
|
|
8261
|
+
*/
|
|
8262
|
+
const pinoIntegration = Object.assign(_pinoIntegration, {
|
|
8263
|
+
trackLogger(logger) {
|
|
8264
|
+
if ((0, _sentry_core.isObjectLike)(logger) && "levels" in logger) logger[SENTRY_TRACK_SYMBOL] = "track";
|
|
8265
|
+
},
|
|
8266
|
+
untrackLogger(logger) {
|
|
8267
|
+
if ((0, _sentry_core.isObjectLike)(logger) && "levels" in logger) logger[SENTRY_TRACK_SYMBOL] = "ignore";
|
|
8268
|
+
}
|
|
8269
|
+
});
|
|
8270
|
+
// src/integrations/winston.ts
|
|
8271
|
+
const DEFAULT_CAPTURED_LEVELS = [
|
|
8272
|
+
"trace",
|
|
8273
|
+
"debug",
|
|
8274
|
+
"info",
|
|
8275
|
+
"warn",
|
|
8276
|
+
"error",
|
|
8277
|
+
"fatal"
|
|
8278
|
+
];
|
|
8279
|
+
const LEVEL_SYMBOL = Symbol.for("level");
|
|
8280
|
+
const MESSAGE_SYMBOL = Symbol.for("message");
|
|
8281
|
+
const SPLAT_SYMBOL = Symbol.for("splat");
|
|
8282
|
+
/**
|
|
8283
|
+
* Creates a new Sentry Winston transport that fowards logs to Sentry.
|
|
8284
|
+
*
|
|
8285
|
+
* Supports Winston 3.x.x.
|
|
8286
|
+
*
|
|
8287
|
+
* @param TransportClass - The Winston transport class to extend.
|
|
8288
|
+
* @returns The extended transport class.
|
|
8289
|
+
*
|
|
8290
|
+
* @example
|
|
8291
|
+
* ```ts
|
|
8292
|
+
* const winston = require('winston');
|
|
8293
|
+
* const Transport = require('winston-transport');
|
|
8294
|
+
*
|
|
8295
|
+
* const SentryWinstonTransport = Sentry.createSentryWinstonTransport(Transport);
|
|
8296
|
+
*
|
|
8297
|
+
* const logger = winston.createLogger({
|
|
8298
|
+
* transports: [new SentryWinstonTransport()],
|
|
8299
|
+
* });
|
|
8300
|
+
* ```
|
|
8301
|
+
*/
|
|
8302
|
+
function createSentryWinstonTransport(TransportClass, sentryWinstonOptions) {
|
|
8303
|
+
class SentryWinstonTransport extends TransportClass {
|
|
8304
|
+
constructor(options) {
|
|
8305
|
+
super(options);
|
|
8306
|
+
this._levels = new Set(sentryWinstonOptions?.levels ?? DEFAULT_CAPTURED_LEVELS);
|
|
8307
|
+
}
|
|
8308
|
+
/**
|
|
8309
|
+
* Forwards a winston log to the Sentry SDK.
|
|
8310
|
+
*/
|
|
8311
|
+
log(info, callback) {
|
|
8312
|
+
try {
|
|
8313
|
+
setImmediate(() => {
|
|
8314
|
+
this.emit("logged", info);
|
|
8315
|
+
});
|
|
8316
|
+
if (!(0, _sentry_core.isObjectLike)(info)) return;
|
|
8317
|
+
const levelFromSymbol = info[LEVEL_SYMBOL];
|
|
8318
|
+
const { level, message, timestamp, ...attributes } = info;
|
|
8319
|
+
attributes[LEVEL_SYMBOL] = void 0;
|
|
8320
|
+
attributes[MESSAGE_SYMBOL] = void 0;
|
|
8321
|
+
attributes[SPLAT_SYMBOL] = void 0;
|
|
8322
|
+
const customLevel = sentryWinstonOptions?.customLevelMap?.[levelFromSymbol];
|
|
8323
|
+
const winstonLogLevel = WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP[levelFromSymbol];
|
|
8324
|
+
const logSeverityLevel = customLevel ?? winstonLogLevel ?? "info";
|
|
8325
|
+
if (this._levels.has(logSeverityLevel)) (0, _sentry_core._INTERNAL_captureLog)({
|
|
8326
|
+
level: logSeverityLevel,
|
|
8327
|
+
message,
|
|
8328
|
+
attributes: {
|
|
8329
|
+
...attributes,
|
|
8330
|
+
[_sentry_conventions_attributes.SENTRY_ORIGIN]: "auto.log.winston"
|
|
8331
|
+
}
|
|
8332
|
+
});
|
|
8333
|
+
else if (!customLevel && !winstonLogLevel) require_debug_build.DEBUG_BUILD && _sentry_core.debug.log(`Winston log level ${levelFromSymbol} is not captured by Sentry. Please add ${levelFromSymbol} to the "customLevelMap" option of the Sentry Winston transport.`);
|
|
8334
|
+
} catch {}
|
|
8335
|
+
if (callback) callback();
|
|
8336
|
+
}
|
|
8337
|
+
}
|
|
8338
|
+
return SentryWinstonTransport;
|
|
8339
|
+
}
|
|
8340
|
+
const WINSTON_LEVEL_TO_LOG_SEVERITY_LEVEL_MAP = {
|
|
8341
|
+
silly: "trace",
|
|
8342
|
+
debug: "debug",
|
|
8343
|
+
verbose: "debug",
|
|
8344
|
+
http: "debug",
|
|
8345
|
+
info: "info",
|
|
8346
|
+
notice: "info",
|
|
8347
|
+
warn: "warn",
|
|
8348
|
+
warning: "warn",
|
|
8349
|
+
error: "error",
|
|
8350
|
+
emerg: "fatal",
|
|
8351
|
+
alert: "fatal",
|
|
8352
|
+
crit: "fatal"
|
|
8353
|
+
};
|
|
7413
8354
|
// src/integrations/openai.ts
|
|
7414
8355
|
const INTEGRATION_NAME$7 = "OpenAI";
|
|
7415
8356
|
const ORIGIN$8 = "auto.ai.openai";
|
|
@@ -7439,12 +8380,13 @@ function instrumentOpenai(options) {
|
|
|
7439
8380
|
for (const { channel, operation } of INSTRUMENTED_CHANNELS) bindTracingChannelToSpan(tracingChannel(channel), (data) => createGenAiSpan(data, operation, options), {
|
|
7440
8381
|
beforeSpanEnd: (span, data) => {
|
|
7441
8382
|
if ("error" in data) require_exports.markCancelledIfAborted(span, require_exports.getRequestSignal(data.arguments?.[1]));
|
|
7442
|
-
require_exports.addResponseAttributes$4(span, data.result,
|
|
8383
|
+
require_exports.addResponseAttributes$4(span, data.result, !!data._sentryRecordOutputs, operation);
|
|
8384
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
7443
8385
|
},
|
|
7444
8386
|
deferSpanEnd: ({ span, data, end }) => wrapApiPromiseResponse(data.result, (response) => {
|
|
7445
8387
|
data.result = response;
|
|
7446
|
-
if (!wrapStreamResult(span, data
|
|
7447
|
-
}, end) || wrapStreamResult(span, data
|
|
8388
|
+
if (!wrapStreamResult(span, data)) end();
|
|
8389
|
+
}, end) || wrapStreamResult(span, data)
|
|
7448
8390
|
});
|
|
7449
8391
|
}
|
|
7450
8392
|
/**
|
|
@@ -7455,7 +8397,12 @@ function createGenAiSpan(data, operation, options) {
|
|
|
7455
8397
|
if (require_exports.shouldSkipAiProviderSpan(INTEGRATION_NAME$7)) return;
|
|
7456
8398
|
const args = data.arguments ?? [];
|
|
7457
8399
|
const params = args[0];
|
|
7458
|
-
const
|
|
8400
|
+
const call = {
|
|
8401
|
+
operation,
|
|
8402
|
+
request: params
|
|
8403
|
+
};
|
|
8404
|
+
const { recordInputs, recordOutputs } = require_exports.resolveGenAiCallRecording(options, call);
|
|
8405
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
7459
8406
|
const attributes = require_exports.extractRequestAttributes$3(args, operation, recordInputs);
|
|
7460
8407
|
attributes[_sentry_conventions_attributes.SENTRY_ORIGIN] = ORIGIN$8;
|
|
7461
8408
|
const model = params?.model || "unknown";
|
|
@@ -7466,6 +8413,8 @@ function createGenAiSpan(data, operation, options) {
|
|
|
7466
8413
|
attributes
|
|
7467
8414
|
});
|
|
7468
8415
|
if (recordInputs && params) require_exports.addRequestAttributes$1(span, params, operation);
|
|
8416
|
+
require_exports.runGenAiSpanStart(options, span, call);
|
|
8417
|
+
data._sentryOnSpanEnd = (result) => require_exports.runGenAiSpanEnd(options, span, call, result);
|
|
7469
8418
|
return span;
|
|
7470
8419
|
}
|
|
7471
8420
|
function isAsyncIterable(value) {
|
|
@@ -7480,12 +8429,11 @@ function isAsyncIterable(value) {
|
|
|
7480
8429
|
* to hand span-ending ownership to `instrumentStream`; `false` for non-streaming/errored results, which end
|
|
7481
8430
|
* via the normal `beforeSpanEnd` path.
|
|
7482
8431
|
*/
|
|
7483
|
-
function wrapStreamResult(span, data
|
|
8432
|
+
function wrapStreamResult(span, data) {
|
|
7484
8433
|
const result = data.result;
|
|
7485
8434
|
if (!isAsyncIterable(result)) return false;
|
|
7486
|
-
const { recordOutputs } = require_exports.resolveAIRecordingOptions(options);
|
|
7487
8435
|
const iterate = result[Symbol.asyncIterator].bind(result);
|
|
7488
|
-
const instrumented = require_exports.instrumentStream$1({ [Symbol.asyncIterator]: iterate }, span,
|
|
8436
|
+
const instrumented = require_exports.instrumentStream$1({ [Symbol.asyncIterator]: iterate }, span, !!data._sentryRecordOutputs, data._sentryOnSpanEnd);
|
|
7489
8437
|
result[Symbol.asyncIterator] = () => instrumented;
|
|
7490
8438
|
return true;
|
|
7491
8439
|
}
|
|
@@ -8144,6 +9092,8 @@ function getProviderMetadataAttributes(providerMetadata) {
|
|
|
8144
9092
|
setAttributeIfDefined(attributes, _sentry_conventions_attributes.GEN_AI_USAGE_TOTAL_TOKENS, googleUsage.totalTokenCount);
|
|
8145
9093
|
setAttributeIfDefined(attributes, _sentry_conventions_attributes.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS, googleUsage.thoughtsTokenCount);
|
|
8146
9094
|
}
|
|
9095
|
+
const gatewayCost = Number(metadata.gateway?.cost);
|
|
9096
|
+
if (metadata.gateway?.cost != null && Number.isFinite(gatewayCost)) attributes[_sentry_conventions_attributes.GEN_AI_COST_TOTAL_TOKENS] = gatewayCost;
|
|
8147
9097
|
return attributes;
|
|
8148
9098
|
}
|
|
8149
9099
|
/**
|
|
@@ -8164,7 +9114,6 @@ function setAttributeIfDefined(attributes, key, value) {
|
|
|
8164
9114
|
if (value != null) attributes[key] = value;
|
|
8165
9115
|
}
|
|
8166
9116
|
// src/integrations/vercel-ai/util.ts
|
|
8167
|
-
/** Shared, state-free helpers for the Vercel AI (`ai`) channel subscribers, plus the streamed model-call tap. */
|
|
8168
9117
|
/** Narrow to a string, or `undefined` for anything else. */
|
|
8169
9118
|
function asString(value) {
|
|
8170
9119
|
return typeof value === "string" ? value : void 0;
|
|
@@ -8186,7 +9135,7 @@ function sum(a, b) {
|
|
|
8186
9135
|
* `try/catch` around every read guarantees the owning span is always ended — a leaked open span on a
|
|
8187
9136
|
* mid-stream failure would be worse than a slightly-less-enriched one.
|
|
8188
9137
|
*/
|
|
8189
|
-
function tapModelCallStream(stream, onFinal, onError) {
|
|
9138
|
+
function tapModelCallStream(span, stream, onFinal, onError) {
|
|
8190
9139
|
const reader = stream.getReader();
|
|
8191
9140
|
const state = { toolCalls: [] };
|
|
8192
9141
|
let text = "";
|
|
@@ -8211,6 +9160,7 @@ function tapModelCallStream(stream, onFinal, onError) {
|
|
|
8211
9160
|
controller.close();
|
|
8212
9161
|
return;
|
|
8213
9162
|
}
|
|
9163
|
+
if (value?.type !== "stream-start") require_exports.recordTimeToFirstChunk(span);
|
|
8214
9164
|
text += accumulateChunk(state, value) ?? "";
|
|
8215
9165
|
controller.enqueue(value);
|
|
8216
9166
|
} catch (error) {
|
|
@@ -8288,6 +9238,13 @@ const ROOT_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
|
8288
9238
|
"embedMany",
|
|
8289
9239
|
"rerank"
|
|
8290
9240
|
]);
|
|
9241
|
+
const PARTIAL_COST_OPERATION_TYPES = /* @__PURE__ */ new Set([
|
|
9242
|
+
"generateText",
|
|
9243
|
+
"streamText",
|
|
9244
|
+
"streamObject",
|
|
9245
|
+
"generateObject",
|
|
9246
|
+
"embedMany"
|
|
9247
|
+
]);
|
|
8291
9248
|
/** Drop the per-operation `callId` maps once the owning top-level operation settles (success or error). */
|
|
8292
9249
|
function clearOperationId(data) {
|
|
8293
9250
|
if (!ROOT_OPERATION_TYPES.has(data.type)) return;
|
|
@@ -8338,6 +9295,7 @@ function dropLastStepOnlyUsage(providerAttributes, type) {
|
|
|
8338
9295
|
const hasRecomputedOutput = _sentry_conventions_attributes.GEN_AI_USAGE_OUTPUT_TOKENS in providerAttributes;
|
|
8339
9296
|
for (const key of LAST_STEP_ONLY_USAGE_KEYS) delete providerAttributes[key];
|
|
8340
9297
|
if (hasRecomputedOutput) delete providerAttributes[_sentry_conventions_attributes.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS];
|
|
9298
|
+
if (PARTIAL_COST_OPERATION_TYPES.has(type)) delete providerAttributes[_sentry_conventions_attributes.GEN_AI_COST_TOTAL_TOKENS];
|
|
8341
9299
|
}
|
|
8342
9300
|
/** Record tool name → description from an event's `tools`, so tool spans can backfill the description. */
|
|
8343
9301
|
function recordToolDescriptions(callId, tools) {
|
|
@@ -8366,7 +9324,13 @@ function resolveToolDescription(callId, toolName, tools) {
|
|
|
8366
9324
|
return (0, _sentry_core.isObjectLike)(tool) ? asString(tool.description) : void 0;
|
|
8367
9325
|
}
|
|
8368
9326
|
}
|
|
9327
|
+
const integrationRecordingBySpan = /* @__PURE__ */ new WeakMap();
|
|
8369
9328
|
const fallbackChannelResults = /* @__PURE__ */ new WeakMap();
|
|
9329
|
+
const spanEndHooks = /* @__PURE__ */ new WeakMap();
|
|
9330
|
+
/** Runs the `onSpanEnd` hook of a span that `createSpanFromMessage` started. Call it right before the span ends. */
|
|
9331
|
+
function runVercelAiSpanEnd(span, result) {
|
|
9332
|
+
spanEndHooks.get(span)?.(result);
|
|
9333
|
+
}
|
|
8370
9334
|
/**
|
|
8371
9335
|
* Subscribe Sentry span handlers to the `ai` SDK's native telemetry tracing channel (`ai:telemetry`,
|
|
8372
9336
|
* available in `ai` >= 7) and emit fully-formed `gen_ai.*` spans directly — no OpenTelemetry span
|
|
@@ -8382,33 +9346,39 @@ const fallbackChannelResults = /* @__PURE__ */ new WeakMap();
|
|
|
8382
9346
|
function subscribeVercelAiTracingChannel(tracingChannel, options = {}) {
|
|
8383
9347
|
bindTracingChannelToSpan(tracingChannel(AI_SDK_TELEMETRY_TRACING_CHANNEL), (data) => createSpanFromMessage(data, options), {
|
|
8384
9348
|
beforeSpanEnd: (span, data) => {
|
|
8385
|
-
enrichSpanOnEnd(span, data
|
|
9349
|
+
enrichSpanOnEnd(span, data);
|
|
9350
|
+
runVercelAiSpanEnd(span, "error" in data ? { error: data.error } : { response: getNonStreamResult(span, data) });
|
|
8386
9351
|
fallbackChannelResults.delete(span);
|
|
8387
9352
|
clearOperationId(data);
|
|
8388
9353
|
},
|
|
8389
|
-
deferSpanEnd: ({ span, data, end }) => deferStreamedModelCallEnd(span, data,
|
|
9354
|
+
deferSpanEnd: ({ span, data, end }) => deferStreamedModelCallEnd(span, data, end)
|
|
8390
9355
|
});
|
|
8391
9356
|
}
|
|
9357
|
+
function getNonStreamResult(span, data) {
|
|
9358
|
+
const result = fallbackChannelResults.get(span) ?? data.result;
|
|
9359
|
+
return (0, _sentry_core.isObjectLike)(result) && require_exports.isReadableStream(result.stream) ? void 0 : result;
|
|
9360
|
+
}
|
|
8392
9361
|
/**
|
|
8393
9362
|
* When a `languageModelCall` resolves to a live `ReadableStream`, defer ending its span: swap in a
|
|
8394
9363
|
* passthrough that forwards chunks to the SDK untouched while aggregating usage/finish/output, then
|
|
8395
9364
|
* enrich and end the span once the stream settles. Returns `false` for anything that isn't a streamed
|
|
8396
9365
|
* model call so the helper ends the span as usual.
|
|
8397
9366
|
*/
|
|
8398
|
-
function deferStreamedModelCallEnd(span, data,
|
|
9367
|
+
function deferStreamedModelCallEnd(span, data, end) {
|
|
8399
9368
|
const result = fallbackChannelResults.get(span) ?? data.result;
|
|
8400
9369
|
if (data.type !== "languageModelCall" || !(0, _sentry_core.isObjectLike)(result)) return false;
|
|
8401
9370
|
const stream = result.stream;
|
|
8402
9371
|
if (!require_exports.isReadableStream(stream)) return false;
|
|
8403
9372
|
const callId = asString(data.event.callId);
|
|
8404
|
-
const
|
|
8405
|
-
|
|
9373
|
+
const invokeAgentSpan = callId ? invokeAgentSpanByCallId.get(callId) : void 0;
|
|
9374
|
+
const { recordOutputs } = getRecordingOptions(data.event, invokeAgentSpan && integrationRecordingBySpan.get(invokeAgentSpan), data.result === void 0);
|
|
9375
|
+
result.stream = tapModelCallStream(span, stream, (final) => {
|
|
8406
9376
|
fallbackChannelResults.set(span, {
|
|
8407
9377
|
...result,
|
|
8408
9378
|
...streamedResultToChannelResult(final)
|
|
8409
9379
|
});
|
|
8410
9380
|
end();
|
|
8411
|
-
enrichInvokeAgentFromStream(
|
|
9381
|
+
if (invokeAgentSpan) enrichInvokeAgentFromStream(invokeAgentSpan, final, recordOutputs);
|
|
8412
9382
|
}, (error) => end(error));
|
|
8413
9383
|
return true;
|
|
8414
9384
|
}
|
|
@@ -8439,9 +9409,7 @@ function streamedResultToChannelResult(final) {
|
|
|
8439
9409
|
* the enclosing `invoke_agent` span, which has no channel result of its own. Runs before that span ends
|
|
8440
9410
|
* because the operation's completion promise settles only after every model-call stream has drained.
|
|
8441
9411
|
*/
|
|
8442
|
-
function enrichInvokeAgentFromStream(
|
|
8443
|
-
const span = callId ? invokeAgentSpanByCallId.get(callId) : void 0;
|
|
8444
|
-
if (!span) return;
|
|
9412
|
+
function enrichInvokeAgentFromStream(span, final, recordOutputs) {
|
|
8445
9413
|
const usage = (0, _sentry_core.isObjectLike)(final.usage) ? final.usage : void 0;
|
|
8446
9414
|
if (usage) {
|
|
8447
9415
|
const input = tokenCount(usage.inputTokens) ?? tokenCount(usage.promptTokens) ?? tokenCount(usage.tokens);
|
|
@@ -8473,7 +9441,23 @@ function addTokensToSpan(span, attribute, value) {
|
|
|
8473
9441
|
function createSpanFromMessage(data, channelOptions) {
|
|
8474
9442
|
const { type, event } = data;
|
|
8475
9443
|
if (type === "step" || !event || typeof event !== "object") return;
|
|
8476
|
-
const
|
|
9444
|
+
const call = {
|
|
9445
|
+
type,
|
|
9446
|
+
event
|
|
9447
|
+
};
|
|
9448
|
+
const integrationRecording = {
|
|
9449
|
+
recordInputs: require_exports.resolveRecordingOption(channelOptions.recordInputs, call),
|
|
9450
|
+
recordOutputs: require_exports.resolveRecordingOption(channelOptions.recordOutputs, call)
|
|
9451
|
+
};
|
|
9452
|
+
const span = startSpanFromEvent(type, event, getRecordingOptions(event, integrationRecording).recordInputs);
|
|
9453
|
+
if (span) {
|
|
9454
|
+
integrationRecordingBySpan.set(span, integrationRecording);
|
|
9455
|
+
require_exports.runGenAiSpanStart(channelOptions, span, call);
|
|
9456
|
+
spanEndHooks.set(span, (result) => require_exports.runGenAiSpanEnd(channelOptions, span, call, result));
|
|
9457
|
+
}
|
|
9458
|
+
return span;
|
|
9459
|
+
}
|
|
9460
|
+
function startSpanFromEvent(type, event, recordInputs) {
|
|
8477
9461
|
const provider = asString(event.provider);
|
|
8478
9462
|
const modelId = asString(event.modelId);
|
|
8479
9463
|
const callId = asString(event.callId);
|
|
@@ -8610,11 +9594,11 @@ function buildToolSpan(event, recordInputs, conversationId, runtimeContextAttrib
|
|
|
8610
9594
|
* Everything here is guarded: when a field is missing or the shape differs across `ai` versions,
|
|
8611
9595
|
* we simply don't set the attribute rather than emit a malformed span.
|
|
8612
9596
|
*/
|
|
8613
|
-
function enrichSpanOnEnd(span, data
|
|
9597
|
+
function enrichSpanOnEnd(span, data) {
|
|
8614
9598
|
const { type } = data;
|
|
8615
9599
|
const result = fallbackChannelResults.get(span) ?? data.result;
|
|
8616
9600
|
if (!(0, _sentry_core.isObjectLike)(result)) return;
|
|
8617
|
-
const { recordOutputs } = getRecordingOptions(data.event,
|
|
9601
|
+
const { recordOutputs } = getRecordingOptions(data.event, integrationRecordingBySpan.get(span), data.result === void 0);
|
|
8618
9602
|
if (type === "executeTool") {
|
|
8619
9603
|
const output = (0, _sentry_core.isObjectLike)(result.output) ? result.output : void 0;
|
|
8620
9604
|
if (output?.type === "tool-error") captureToolError(span, data, output.error);
|
|
@@ -8764,13 +9748,13 @@ function captureToolError(span, data, error) {
|
|
|
8764
9748
|
} });
|
|
8765
9749
|
});
|
|
8766
9750
|
}
|
|
8767
|
-
function getRecordingOptions(event,
|
|
9751
|
+
function getRecordingOptions(event, integrationRecording = {}, channelWithheldResult = false) {
|
|
8768
9752
|
const client = (0, _sentry_core.getClient)();
|
|
8769
9753
|
const genAI = client?.getDataCollectionOptions().genAI;
|
|
8770
9754
|
const eveMode = client && !channelWithheldResult ? isEveGenAiRecordingDefault(client) : false;
|
|
8771
9755
|
return {
|
|
8772
|
-
recordInputs: resolveRecording(
|
|
8773
|
-
recordOutputs: resolveRecording(
|
|
9756
|
+
recordInputs: resolveRecording(integrationRecording.recordInputs, event.recordInputs, genAI?.inputs, eveMode),
|
|
9757
|
+
recordOutputs: resolveRecording(integrationRecording.recordOutputs, event.recordOutputs, genAI?.outputs, eveMode)
|
|
8774
9758
|
};
|
|
8775
9759
|
}
|
|
8776
9760
|
/**
|
|
@@ -8986,12 +9970,14 @@ function bindOperation(tracingChannel, channelName, build, options) {
|
|
|
8986
9970
|
if (callSiteSpan && (0, _sentry_core.isObjectLike)(data.error)) (0, _sentry_core.addNonEnumerableProperty)(data.error, "_sentry_active_span", callSiteSpan);
|
|
8987
9971
|
} else {
|
|
8988
9972
|
message.result = message.type === "executeTool" ? { output: data.result } : data.result;
|
|
8989
|
-
enrichSpanOnEnd(span, message
|
|
9973
|
+
enrichSpanOnEnd(span, message);
|
|
8990
9974
|
}
|
|
8991
|
-
|
|
9975
|
+
const isStream = message.type === "streamText" || message.type === "streamObject";
|
|
9976
|
+
runVercelAiSpanEnd(span, "error" in data ? { error: data.error } : { response: isStream ? void 0 : message.result });
|
|
9977
|
+
if (!isStream) clearOperationId(message);
|
|
8992
9978
|
messages.delete(data);
|
|
8993
9979
|
},
|
|
8994
|
-
deferSpanEnd: ({ span, data, end }) => deferStreamTextOperationEnd(span, data, end
|
|
9980
|
+
deferSpanEnd: ({ span, data, end }) => deferStreamTextOperationEnd(span, data, end)
|
|
8995
9981
|
});
|
|
8996
9982
|
}
|
|
8997
9983
|
/**
|
|
@@ -9004,7 +9990,7 @@ function bindOperation(tracingChannel, channelName, build, options) {
|
|
|
9004
9990
|
* succeeded and `usage` resolved. It's awaited separately so that case still records the token usage on
|
|
9005
9991
|
* the span before ending it as an error.
|
|
9006
9992
|
*/
|
|
9007
|
-
function deferStreamTextOperationEnd(span, data, end
|
|
9993
|
+
function deferStreamTextOperationEnd(span, data, end) {
|
|
9008
9994
|
const message = messages.get(data);
|
|
9009
9995
|
const type = message?.type;
|
|
9010
9996
|
if (!message || type !== "streamText" && type !== "streamObject" || "error" in data || !isStreamingResult(data.result)) return false;
|
|
@@ -9029,7 +10015,7 @@ function deferStreamTextOperationEnd(span, data, end, options) {
|
|
|
9029
10015
|
finishReason,
|
|
9030
10016
|
response
|
|
9031
10017
|
};
|
|
9032
|
-
enrichSpanOnEnd(span, message
|
|
10018
|
+
enrichSpanOnEnd(span, message);
|
|
9033
10019
|
end(objectOutcome.error);
|
|
9034
10020
|
return;
|
|
9035
10021
|
}
|
|
@@ -9158,34 +10144,34 @@ function patchModelMethod(model, method, options) {
|
|
|
9158
10144
|
code: _sentry_core.SPAN_STATUS_ERROR,
|
|
9159
10145
|
message: error instanceof Error ? error.message : "unknown_error"
|
|
9160
10146
|
});
|
|
9161
|
-
span
|
|
10147
|
+
endSpan(span, { error });
|
|
9162
10148
|
clearStreamCallId();
|
|
9163
10149
|
throw error;
|
|
9164
10150
|
};
|
|
9165
10151
|
try {
|
|
9166
10152
|
return Promise.resolve(original.apply(this, args)).then((value) => {
|
|
9167
10153
|
if (method === "doStream" && (0, _sentry_core.isObjectLike)(value) && require_exports.isReadableStream(value.stream)) {
|
|
9168
|
-
value.stream = tapModelCallStream(value.stream, (final) => {
|
|
10154
|
+
value.stream = tapModelCallStream(span, value.stream, (final) => {
|
|
9169
10155
|
message.result = {
|
|
9170
10156
|
...value,
|
|
9171
10157
|
...streamedResultToChannelResult(final)
|
|
9172
10158
|
};
|
|
9173
|
-
enrichSpanOnEnd(span, message
|
|
9174
|
-
span
|
|
10159
|
+
enrichSpanOnEnd(span, message);
|
|
10160
|
+
endSpan(span, {});
|
|
9175
10161
|
clearStreamCallId();
|
|
9176
10162
|
}, (error) => {
|
|
9177
10163
|
span.setStatus({
|
|
9178
10164
|
code: _sentry_core.SPAN_STATUS_ERROR,
|
|
9179
10165
|
message: error instanceof Error ? error.message : "unknown_error"
|
|
9180
10166
|
});
|
|
9181
|
-
span
|
|
10167
|
+
endSpan(span, { error });
|
|
9182
10168
|
clearStreamCallId();
|
|
9183
10169
|
});
|
|
9184
10170
|
return value;
|
|
9185
10171
|
}
|
|
9186
10172
|
message.result = value;
|
|
9187
|
-
enrichSpanOnEnd(span, message
|
|
9188
|
-
span
|
|
10173
|
+
enrichSpanOnEnd(span, message);
|
|
10174
|
+
endSpan(span, { response: value });
|
|
9189
10175
|
clearStreamCallId();
|
|
9190
10176
|
return value;
|
|
9191
10177
|
}, failSpan);
|
|
@@ -9237,14 +10223,14 @@ function patchToolExecute(toolName, tool, tools, options) {
|
|
|
9237
10223
|
message: error instanceof Error ? error.message : "tool_error"
|
|
9238
10224
|
});
|
|
9239
10225
|
else captureToolError(span, message, error);
|
|
9240
|
-
span
|
|
10226
|
+
endSpan(span, { error });
|
|
9241
10227
|
throw error;
|
|
9242
10228
|
};
|
|
9243
10229
|
try {
|
|
9244
10230
|
return Promise.resolve(original.apply(this, [input, ...rest])).then((value) => {
|
|
9245
10231
|
message.result = { output: value };
|
|
9246
|
-
enrichSpanOnEnd(span, message
|
|
9247
|
-
span.
|
|
10232
|
+
enrichSpanOnEnd(span, message);
|
|
10233
|
+
endSpan(span, { response: message.result });
|
|
9248
10234
|
return value;
|
|
9249
10235
|
}, failSpan);
|
|
9250
10236
|
} catch (error) {
|
|
@@ -9252,6 +10238,10 @@ function patchToolExecute(toolName, tool, tools, options) {
|
|
|
9252
10238
|
}
|
|
9253
10239
|
};
|
|
9254
10240
|
}
|
|
10241
|
+
function endSpan(span, result) {
|
|
10242
|
+
runVercelAiSpanEnd(span, result);
|
|
10243
|
+
span.end();
|
|
10244
|
+
}
|
|
9255
10245
|
function buildTextMessage(type) {
|
|
9256
10246
|
return (options, telemetry) => ({
|
|
9257
10247
|
type,
|
|
@@ -9555,7 +10545,7 @@ function getSpanForLayer(data, options) {
|
|
|
9555
10545
|
if (!req) return;
|
|
9556
10546
|
if (!(0, _sentry_core.getActiveSpan)()) return;
|
|
9557
10547
|
const type = getLayerType(layer);
|
|
9558
|
-
const registeredPath = getLayerRegisteredPath(layer);
|
|
10548
|
+
const registeredPath = getLayerRegisteredPath(layer) ?? getMatchedLayerPath(layer);
|
|
9559
10549
|
if (registeredPath != null) {
|
|
9560
10550
|
pushLayerPath(req, registeredPath);
|
|
9561
10551
|
data._sentryStoredLayer = true;
|
|
@@ -9607,6 +10597,15 @@ function getSpanForLayer(data, options) {
|
|
|
9607
10597
|
}
|
|
9608
10598
|
return span;
|
|
9609
10599
|
}
|
|
10600
|
+
/**
|
|
10601
|
+
* The path of a matched layer for which no registration event recorded a path. That is the case when the events
|
|
10602
|
+
* arrive after the registration calls: Cloudflare delivers the events of calls at module scope with the first
|
|
10603
|
+
* request.
|
|
10604
|
+
*/
|
|
10605
|
+
function getMatchedLayerPath(layer) {
|
|
10606
|
+
if (layer.route) return getLayerPath([layer.route.path]);
|
|
10607
|
+
return layer.keys?.length ? void 0 : layer.path || void 0;
|
|
10608
|
+
}
|
|
9610
10609
|
function getLayerType(layer) {
|
|
9611
10610
|
if (layer.name === "router") return "router";
|
|
9612
10611
|
if (layer.name === "bound dispatch" || layer.name === "handle") return "request_handler";
|
|
@@ -10315,7 +11314,9 @@ function getErrorIntegrations() {
|
|
|
10315
11314
|
* @deprecated This is a temporary export to avoid breaking changes. It will be removed in the next major version.
|
|
10316
11315
|
*/
|
|
10317
11316
|
const attachHapiErrorHandler = attachHapiErrorHandler$1;
|
|
11317
|
+
exports.BullMQTelemetry = BullMQTelemetry;
|
|
10318
11318
|
exports.SentryMastraExporter = require_exports.SentryMastraExporter;
|
|
11319
|
+
exports._INTERNAL_cronExpressionToMonitorConfig = cronExpressionToMonitorConfig;
|
|
10319
11320
|
exports._INTERNAL_instrumentTunnelServer = instrumentTunnelServer;
|
|
10320
11321
|
exports._INTERNAL_instrumentTunnelServers = instrumentTunnelServers;
|
|
10321
11322
|
exports.amqplibIntegration = amqplibIntegration;
|
|
@@ -10328,6 +11329,8 @@ exports.bindTracingChannelToSpan = bindTracingChannelToSpan;
|
|
|
10328
11329
|
exports.createFlueInstrumentation = require_exports.createFlueInstrumentation;
|
|
10329
11330
|
exports.createHonoRequestMiddleware = require_exports.createHonoRequestMiddleware;
|
|
10330
11331
|
exports.createLangChainCallbackHandler = require_exports.createLangChainCallbackHandler;
|
|
11332
|
+
exports.createSentryWinstonTransport = createSentryWinstonTransport;
|
|
11333
|
+
exports.cron = cron;
|
|
10331
11334
|
exports.cronJobIntegration = cronJobIntegration;
|
|
10332
11335
|
exports.dataloaderIntegration = dataloaderIntegration;
|
|
10333
11336
|
exports.detectOrchestrionSetup = require_exports.detectOrchestrionSetup;
|
|
@@ -10392,6 +11395,7 @@ exports.openTelemetryIntegration = require_exports.openTelemetryIntegration;
|
|
|
10392
11395
|
exports.orchestrionModuleInjected = orchestrionModuleInjected;
|
|
10393
11396
|
exports.piAiIntegration = piAiIntegration;
|
|
10394
11397
|
exports.piDurableIntegration = piDurableIntegration;
|
|
11398
|
+
exports.pinoIntegration = pinoIntegration;
|
|
10395
11399
|
exports.postgresIntegration = postgresIntegration;
|
|
10396
11400
|
exports.postgresJsIntegration = postgresJsIntegration;
|
|
10397
11401
|
exports.prismaIntegration = prismaIntegration;
|