@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
|
@@ -28,7 +28,7 @@ function onSetTime({ arguments: [cronTime], self }) {
|
|
|
28
28
|
const job = self;
|
|
29
29
|
if (!job || job.cronTime !== cronTime) return;
|
|
30
30
|
const { source, timeZone, utcOffset } = cronTime;
|
|
31
|
-
const monitorConfig = typeof source === "string" && utcOffset == null ? cronExpressionToMonitorConfig(source, timeZone, "
|
|
31
|
+
const monitorConfig = typeof source === "string" && utcOffset == null ? cronExpressionToMonitorConfig(source, timeZone, "cron") : void 0;
|
|
32
32
|
for (const callback of job._callbacks || []) updateMonitorConfig(callback, monitorConfig);
|
|
33
33
|
}
|
|
34
34
|
function wrapJob(args, options) {
|
|
@@ -36,7 +36,7 @@ function wrapJob(args, options) {
|
|
|
36
36
|
const utcOffset = args[7];
|
|
37
37
|
const name = args[11];
|
|
38
38
|
if (typeof cronTime !== "string" || !shouldMonitorJob(name, onTick, options.excludeJobs)) return;
|
|
39
|
-
const monitorConfig = utcOffset == null ? cronExpressionToMonitorConfig(cronTime, timeZone, "
|
|
39
|
+
const monitorConfig = utcOffset == null ? cronExpressionToMonitorConfig(cronTime, timeZone, "cron") : void 0;
|
|
40
40
|
args[1] = wrapScheduledJob(onTick, name, monitorConfig, "auto.function.cron");
|
|
41
41
|
}
|
|
42
42
|
export { cronJobIntegration, onSetTime };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cron.js","names":[],"sources":["../../../src/integrations/cron.ts"],"sourcesContent":["import type { IntegrationFn, MonitorConfig } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { cronModuleNames } from '../orchestrion/config/cron';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\nimport type { AnyFn, ScheduleChange } from '../utils/cronMonitoring';\nimport {\n cronExpressionToMonitorConfig,\n shouldMonitorJob,\n subscribeToJobCreation,\n subscribeToScheduleChange,\n updateMonitorConfig,\n wrapScheduledJob,\n} from '../utils/cronMonitoring';\n\nconst INTEGRATION_NAME = 'CronJob' as const;\n\nexport interface CronJobIntegrationOptions {\n /** Job names not to monitor. Strings must match the name exactly. */\n excludeJobs?: Array<string | RegExp>;\n}\n\nconst _cronJobIntegration = ((options: CronJobIntegrationOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, cronModuleNames, subscribe, [options], {\n requiresTracingChannelBinding: false,\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Sends Crons check-ins for every `CronJob` of the `cron` package (4.3+) that has a `name`.\n * The monitor slug is the job name. Jobs without a name, one-off jobs, and jobs with a schedule Crons can't express\n * are not monitored.\n */\nexport const cronJobIntegration = defineIntegration(_cronJobIntegration);\n\nfunction subscribe(options: CronJobIntegrationOptions): void {\n subscribeToJobCreation(CHANNELS.CRON_JOB_CONSTRUCTOR, INTEGRATION_NAME, args => wrapJob(args, options));\n subscribeToScheduleChange(CHANNELS.CRON_JOB_SET_TIME, INTEGRATION_NAME, onSetTime);\n}\n\n/** Sets the new time's config after `job.setTime(cronTime)`. Without one, the job doesn't check in. */\nexport function onSetTime({ arguments: [cronTime], self }: ScheduleChange): void {\n const job = self as { cronTime?: unknown; _callbacks?: unknown[] } | undefined;\n // `setTime` throws and keeps the old time when it isn't given a `CronTime`.\n if (!job || job.cronTime !== cronTime) {\n return;\n }\n const { source, timeZone, utcOffset } = cronTime as { source?: unknown; timeZone?: unknown; utcOffset?: unknown };\n const monitorConfig: MonitorConfig | undefined =\n typeof source === 'string' && utcOffset == null
|
|
1
|
+
{"version":3,"file":"cron.js","names":[],"sources":["../../../src/integrations/cron.ts"],"sourcesContent":["import type { IntegrationFn, MonitorConfig } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { cronModuleNames } from '../orchestrion/config/cron';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\nimport type { AnyFn, ScheduleChange } from '../utils/cronMonitoring';\nimport {\n cronExpressionToMonitorConfig,\n shouldMonitorJob,\n subscribeToJobCreation,\n subscribeToScheduleChange,\n updateMonitorConfig,\n wrapScheduledJob,\n} from '../utils/cronMonitoring';\n\nconst INTEGRATION_NAME = 'CronJob' as const;\n\nexport interface CronJobIntegrationOptions {\n /** Job names not to monitor. Strings must match the name exactly. */\n excludeJobs?: Array<string | RegExp>;\n}\n\nconst _cronJobIntegration = ((options: CronJobIntegrationOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, cronModuleNames, subscribe, [options], {\n requiresTracingChannelBinding: false,\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Sends Crons check-ins for every `CronJob` of the `cron` package (4.3+) that has a `name`.\n * The monitor slug is the job name. Jobs without a name, one-off jobs, and jobs with a schedule Crons can't express\n * are not monitored.\n */\nexport const cronJobIntegration = defineIntegration(_cronJobIntegration);\n\nfunction subscribe(options: CronJobIntegrationOptions): void {\n subscribeToJobCreation(CHANNELS.CRON_JOB_CONSTRUCTOR, INTEGRATION_NAME, args => wrapJob(args, options));\n subscribeToScheduleChange(CHANNELS.CRON_JOB_SET_TIME, INTEGRATION_NAME, onSetTime);\n}\n\n/** Sets the new time's config after `job.setTime(cronTime)`. Without one, the job doesn't check in. */\nexport function onSetTime({ arguments: [cronTime], self }: ScheduleChange): void {\n const job = self as { cronTime?: unknown; _callbacks?: unknown[] } | undefined;\n // `setTime` throws and keeps the old time when it isn't given a `CronTime`.\n if (!job || job.cronTime !== cronTime) {\n return;\n }\n const { source, timeZone, utcOffset } = cronTime as { source?: unknown; timeZone?: unknown; utcOffset?: unknown };\n const monitorConfig: MonitorConfig | undefined =\n typeof source === 'string' && utcOffset == null\n ? cronExpressionToMonitorConfig(source, timeZone, 'cron')\n : undefined;\n for (const callback of job._callbacks || []) {\n updateMonitorConfig(callback, monitorConfig);\n }\n}\n\n// `new CronJob(cronTime, onTick, onComplete, start, timeZone, context, runOnInit, utcOffset, ..., name)`\nfunction wrapJob(args: unknown[], options: CronJobIntegrationOptions): void {\n const [cronTime, onTick, , , timeZone] = args;\n const utcOffset = args[7];\n const name = args[11];\n if (typeof cronTime !== 'string' || !shouldMonitorJob(name, onTick, options.excludeJobs)) {\n return;\n }\n const monitorConfig = utcOffset == null ? cronExpressionToMonitorConfig(cronTime, timeZone, 'cron') : undefined;\n args[1] = wrapScheduledJob(onTick as AnyFn, name, monitorConfig, 'auto.function.cron');\n}\n"],"mappings":";;;;;;AAeA,MAAM,mBAAmB;AAOzB,MAAM,wBAAwB,UAAqC,CAAC,MAAM;CACxE,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GACZ,iCAAiC,QAAQ,iBAAiB,WAAW,CAAC,OAAO,GAAG,EAC9E,+BAA+B,MACjC,CAAC;EACH;CACF;AACF;;;;;;AAOA,MAAa,qBAAqB,kBAAkB,mBAAmB;AAEvE,SAAS,UAAU,SAA0C;CAC3D,uBAAuB,SAAS,sBAAsB,mBAAkB,SAAQ,QAAQ,MAAM,OAAO,CAAC;CACtG,0BAA0B,SAAS,mBAAmB,kBAAkB,SAAS;AACnF;;AAGA,SAAgB,UAAU,EAAE,WAAW,CAAC,WAAW,QAA8B;CAC/E,MAAM,MAAM;CAEZ,IAAI,CAAC,OAAO,IAAI,aAAa,UAC3B;CAEF,MAAM,EAAE,QAAQ,UAAU,cAAc;CACxC,MAAM,gBACJ,OAAO,WAAW,YAAY,aAAa,OACvC,8BAA8B,QAAQ,UAAU,MAAM,IACtD,KAAA;CACN,KAAK,MAAM,YAAY,IAAI,cAAc,CAAC,GACxC,oBAAoB,UAAU,aAAa;AAE/C;AAGA,SAAS,QAAQ,MAAiB,SAA0C;CAC1E,MAAM,CAAC,UAAU,YAAY,YAAY;CACzC,MAAM,YAAY,KAAK;CACvB,MAAM,OAAO,KAAK;CAClB,IAAI,OAAO,aAAa,YAAY,CAAC,iBAAiB,MAAM,QAAQ,QAAQ,WAAW,GACrF;CAEF,MAAM,gBAAgB,aAAa,OAAO,8BAA8B,UAAU,UAAU,MAAM,IAAI,KAAA;CACtG,KAAK,KAAK,iBAAiB,QAAiB,MAAM,eAAe,oBAAoB;AACvF"}
|
|
@@ -127,7 +127,7 @@ function getSpanForLayer(data, options) {
|
|
|
127
127
|
if (!req) return;
|
|
128
128
|
if (!getActiveSpan()) return;
|
|
129
129
|
const type = getLayerType(layer);
|
|
130
|
-
const registeredPath = getLayerRegisteredPath(layer);
|
|
130
|
+
const registeredPath = getLayerRegisteredPath(layer) ?? getMatchedLayerPath(layer);
|
|
131
131
|
if (registeredPath != null) {
|
|
132
132
|
pushLayerPath(req, registeredPath);
|
|
133
133
|
data._sentryStoredLayer = true;
|
|
@@ -179,6 +179,15 @@ function getSpanForLayer(data, options) {
|
|
|
179
179
|
}
|
|
180
180
|
return span;
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* The path of a matched layer for which no registration event recorded a path. That is the case when the events
|
|
184
|
+
* arrive after the registration calls: Cloudflare delivers the events of calls at module scope with the first
|
|
185
|
+
* request.
|
|
186
|
+
*/
|
|
187
|
+
function getMatchedLayerPath(layer) {
|
|
188
|
+
if (layer.route) return getLayerPath([layer.route.path]);
|
|
189
|
+
return layer.keys?.length ? void 0 : layer.path || void 0;
|
|
190
|
+
}
|
|
182
191
|
function getLayerType(layer) {
|
|
183
192
|
if (layer.name === "router") return "router";
|
|
184
193
|
if (layer.name === "bound dispatch" || layer.name === "handle") return "request_handler";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumentation.js","names":[],"sources":["../../../../src/integrations/express/instrumentation.ts"],"sourcesContent":["import type * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { HTTP_ROUTE, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { HANDLER, MIDDLEWARE, ROUTER } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n captureException,\n debug,\n getActiveSpan,\n getClient,\n getDefaultIsolationScope,\n getIsolationScope,\n hasSpanStreamingEnabled,\n REQUEST_HANDLER_SPAN_NAME_FALLBACK,\n ROUTER_SPAN_NAME_FALLBACK,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n stringMatchesSomePattern,\n withActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\nimport {\n getActualMatchedRoute,\n getConstructedRoute,\n getLayerPath,\n getLayerRegisteredPath,\n popLayerPath,\n pushLayerPath,\n setLayerRegisteredPath,\n} from './route';\nimport type {\n ExpressIntegrationOptions,\n ExpressLayer,\n ExpressLayerType,\n ExpressRequest,\n ExpressResponse,\n ExpressShouldHandleError,\n HandleChannelContext,\n MiddlewareError,\n RegistrationChannelContext,\n} from './types';\nimport { defaultShouldHandleError } from './utils';\nimport { isExpressErrorHandled, markExpressErrorHandled } from './error-handled';\nimport { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';\n\nconst ORIGIN = 'auto.http.express';\n\n// `express.name`/`express.type` are Sentry-internal Express attributes (not part\n// of `@sentry/conventions`); kept in sync with `@sentry/core`'s OTel-derived\n// Express integration so the emitted spans are identical across both code paths.\nconst ATTR_EXPRESS_NAME = 'express.name';\nconst ATTR_EXPRESS_TYPE = 'express.type';\n\nconst EXPRESS_TYPE_TO_SPAN_OP: Record<string, string> = {\n middleware: MIDDLEWARE,\n request_handler: HANDLER,\n router: ROUTER,\n};\n\nconst NOOP = (): void => {};\n\nlet _isInstrumented = false;\n\nexport function instrumentExpress(\n options: ExpressIntegrationOptions,\n tracingChannel: typeof diagnosticsChannel.tracingChannel,\n): void {\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n // Record each layer's registered path *pattern* as it is registered, so the\n // matched route can be reconstructed with its parameters intact at request\n // time. Only the `end` event matters (the layer is on the router's stack by\n // then); the others are required by the subscriber type, so no-op them.\n for (const channelName of [CHANNELS.EXPRESS_REGISTER, CHANNELS.ROUTER_REGISTER]) {\n tracingChannel<RegistrationChannelContext>(channelName).subscribe({\n start: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n end: captureRegisteredLayerPath,\n });\n }\n\n for (const channelName of [CHANNELS.EXPRESS_HANDLE, CHANNELS.ROUTER_HANDLE]) {\n const channel = tracingChannel<HandleChannelContext>(channelName);\n\n bindTracingChannelToSpan(channel, data => getSpanForLayer(data, options), {\n beforeSpanEnd(_span, data) {\n data._sentryCleanup?.();\n },\n });\n\n // Pop the layer path and end the layer span when the layer hands off via\n // `next`. `asyncStart` fires when `next` is called and *before* the\n // downstream layer runs, so the per-request path chain reflects only the\n // current chain when each layer reconstructs its route, and each span covers\n // only its own layer. The `error` event captures throws at the layer level\n // (see `captureLayerError`), before any user error-handling middleware.\n channel.subscribe({\n start: NOOP,\n asyncEnd: NOOP,\n end: NOOP,\n error: data => captureLayerError(data, options.shouldHandleError),\n asyncStart: data => {\n popLayerPathForLayer(data);\n endLayerSpanOnNext(data);\n },\n });\n }\n}\n\n/**\n * Capture an error surfaced on a layer's `handle_request` channel — the throw\n * site, which runs before any user error-handling middleware.\n *\n * Each request's error is handled exactly once: the same error surfaces on every\n * parent layer's `error` event as it bubbles, and a user may also still call the\n * deprecated `setupExpressErrorHandler`. We mark the request the first time we\n * see it, so later layers and that middleware defer to this decision — the\n * integration is the single registered handler and its `shouldHandleError` wins.\n * This deliberately does not rely on `captureException`'s global dedup, which is\n * only set when an error is actually captured and so cannot express a\n * \"deliberately skipped\" decision (leaving the deprecated middleware free to\n * capture it and override `shouldHandleError`).\n *\n * `shouldHandleError` is the raw integration option: `false` disables capture\n * entirely, a function customizes the gate, and `undefined` falls back to\n * {@link defaultShouldHandleError}.\n */\nexport function captureLayerError(\n data: HandleChannelContext,\n shouldHandleError: ExpressShouldHandleError | undefined,\n): void {\n const error = data.error;\n\n // `next('route')` / `next('router')` are Express control-flow signals, not errors.\n if (!error || error === 'route' || error === 'router') {\n return;\n }\n\n // Take responsibility for this request's error exactly once (see the doc comment above). The marker\n // lives on the request — the same instance across every bubbling layer and the error middleware,\n // and always a mutable object, unlike the thrown value which may be frozen or a primitive. Mark\n // before the `shouldHandleError` gate so a \"skip\" decision also suppresses the deprecated middleware.\n const request = data.arguments?.[0] as ExpressRequest | undefined;\n if (request) {\n if (isExpressErrorHandled(request)) {\n return;\n }\n markExpressErrorHandled(request);\n }\n\n if (shouldHandleError === false) {\n return;\n }\n\n if (!(shouldHandleError ?? defaultShouldHandleError)(error as MiddlewareError)) {\n return;\n }\n\n const capture = (): string =>\n captureException(error, {\n mechanism: {\n type: 'auto.http.express',\n handled: false,\n },\n });\n\n // The channel's `error` event runs outside the layer span's async context, so\n // re-activate the bound span (when present) to parent the error event to the\n // request's trace instead of capturing it context-free.\n if (data._sentrySpan) {\n withActiveSpan(data._sentrySpan, capture);\n } else {\n capture();\n }\n}\n\n/** Record the freshly-registered layer's path pattern from a `route`/`use` call. */\nfunction captureRegisteredLayerPath(data: RegistrationChannelContext): void {\n const stack = data.self?.stack;\n if (!Array.isArray(stack)) {\n return;\n }\n const layer = stack[stack.length - 1];\n if (layer) {\n setLayerRegisteredPath(layer, getLayerPath(data.arguments ?? []));\n }\n}\n\n/** Pop the path a layer pushed once it hands control onward via `next`. */\nfunction popLayerPathForLayer(data: HandleChannelContext): void {\n if (!data._sentryStoredLayer) {\n return;\n }\n // Clear the marker first so a layer that (incorrectly) calls `next` more than\n // once can't pop again and take a parent's entry off the stack with it.\n data._sentryStoredLayer = false;\n const req = data.arguments?.[0] as ExpressRequest | undefined;\n if (req) {\n popLayerPath(req);\n }\n}\n\n/**\n * End a layer's span once it hands control onward via `next`.\n *\n * The tracing-channel helper would otherwise end it on `asyncEnd`, which only\n * fires once `next` *returns*. Express runs the rest of the chain synchronously\n * inside `next`, so that would keep every layer on the synchronous chain open\n * (each holding a response `finish` listener) until the whole chain unwinds,\n * and inflate each span with the downstream layers' synchronous work. The\n * helper's later `asyncEnd` is then a no-op, since `span.end()` is idempotent.\n */\nfunction endLayerSpanOnNext(data: HandleChannelContext): void {\n const span = data._sentrySpan;\n if (!span) {\n return;\n }\n data._sentryCleanup?.();\n span.end();\n}\n\n/**\n * Open a span for one layer invocation. Returns `undefined` to opt the layer\n * out (error handlers, or a layer with no active parent trace) — the helper\n * then leaves the active context untouched.\n */\nfunction getSpanForLayer(data: HandleChannelContext, options: ExpressIntegrationOptions): Span | undefined {\n const layer = data.self;\n const args = data.arguments;\n if (!layer || !Array.isArray(args)) {\n return undefined;\n }\n\n // Express only treats a 4-arg handler as an error handler and skips it in\n // the normal request pipeline; match the OTel integration and don't trace it.\n if (layer.handle?.length === 4) {\n return undefined;\n }\n\n // A Route dispatches to its handlers via the same `handle_request` method,\n // but those inner layers already run inside the route-dispatch layer's\n // `request_handler` span. They carry `.method` (and no `.route`); skip them\n // so we emit one span per route, matching the OTel Express integration.\n if (layer.method && !layer.route) {\n return undefined;\n }\n\n const req = args[0] as ExpressRequest | undefined;\n const res = args[1] as ExpressResponse | undefined;\n if (!req) {\n return undefined;\n }\n\n // No active parent span means this request is being ignored (unsampled /\n // filtered), so don't open a span\n if (!getActiveSpan()) {\n return undefined;\n }\n\n const type = getLayerType(layer);\n\n // Push this layer's registered path onto the request's chain so a\n // `request_handler` can reconstruct the full route with parameters intact\n // (`req.baseUrl` only exposes the *resolved* mount prefix). The matching pop\n // happens on `asyncStart` when the layer hands off via `next`.\n const registeredPath = getLayerRegisteredPath(layer);\n if (registeredPath != null) {\n pushLayerPath(req, registeredPath);\n data._sentryStoredLayer = true;\n }\n\n // `constructedRoute` (the full registered pattern) names the span/transaction;\n // `matchedRoute` (validated against the request URL) is the `http.route`.\n // Computed for every layer type (not just `request_handler`) so routes served\n // by mounted middleware (`app.use('/trpc', handler)`) still propagate their\n // path to the root `http.server` span — mirroring the OTel Express integration,\n // which resolves the route on every layer. Without this, such transactions keep\n // the raw URL name (e.g. `GET /trpc/foo` instead of `GET /trpc`).\n const constructedRoute = getConstructedRoute(req);\n const matchedRoute = constructedRoute != null ? getActualMatchedRoute(req, constructedRoute) : undefined;\n\n const name =\n type === 'request_handler'\n ? constructedRoute || 'request handler'\n : type === 'router'\n ? (layer.path ?? '/')\n : (layer.name ?? '<anonymous>');\n\n // Propagate the route to the root `http.server` span *before* the ignore\n // check, so the transaction is still named even when the layer's own span is\n // ignored — matches the OTel Express integration's `onRouteResolved` timing.\n if (matchedRoute) {\n setHttpServerSpanRouteAttribute(matchedRoute);\n }\n\n if (type === 'request_handler' && constructedRoute) {\n const isolationScope = getIsolationScope();\n if (isolationScope !== getDefaultIsolationScope()) {\n const method = typeof req.method === 'string' ? req.method.toUpperCase() : 'GET';\n isolationScope.setTransactionName(`${method} ${constructedRoute}`);\n } else {\n DEBUG_BUILD &&\n debug.warn(\n '[instrumentation:express] Isolation scope is still default isolation scope - skipping transaction name',\n );\n }\n }\n\n // Honor `ignoreLayers`/`ignoreLayersType`: skip the span for matching layers.\n // We intentionally do NOT pop the pushed path here (unlike OTel Express, which\n // pops on ignore): the path is still popped on `asyncStart` when the layer\n // calls `next`, so a following sibling isn't polluted, while an ignored\n // *router* keeps its mount prefix on the stack for the sub-stack it dispatches\n // — so routes under an ignored router stay correct. The only entries that\n // never pop come from layers that end the response without `next()`, and those\n // sit on a per-request store that is discarded when the request ends.\n if (isLayerIgnored(name, type, options)) {\n return undefined;\n }\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so router\n // and request handler spans are named after their route. A route that did\n // not validate against the request URL can describe a different request,\n // so those spans take the static fallback instead.\n const isStreamedSpan = !!client && hasSpanStreamingEnabled(client);\n const isStreamedRouterSpan = isStreamedSpan && type === 'router';\n const isStreamedRequestHandlerSpan = isStreamedSpan && type === 'request_handler';\n\n const span = startInactiveSpan({\n name: isStreamedRouterSpan\n ? matchedRoute || ROUTER_SPAN_NAME_FALLBACK\n : isStreamedRequestHandlerSpan\n ? matchedRoute || REQUEST_HANDLER_SPAN_NAME_FALLBACK\n : name,\n attributes: {\n [SENTRY_ORIGIN]: ORIGIN,\n [SENTRY_OP]: EXPRESS_TYPE_TO_SPAN_OP[type],\n [ATTR_EXPRESS_NAME]: name,\n [ATTR_EXPRESS_TYPE]: type,\n [HTTP_ROUTE]: matchedRoute,\n },\n });\n\n // A layer that sends the response (route handlers, typically) never calls\n // `next`, so the channel's `asyncStart` never fires. End on the response's\n // `finish` in that case. When `next` *is* called, `endLayerSpanOnNext` ends\n // the span and removes these now-redundant listeners.\n // `finish` never fires when the client aborts, so also end on `close`, which\n // is when the `http.server` span ends. Otherwise the span and its subtree\n // would be dropped from the transaction.\n if (res && typeof res.once === 'function') {\n const cleanup = (): void => {\n res.removeListener('finish', onFinish);\n res.removeListener('close', onClose);\n };\n const onFinish = (): void => {\n cleanup();\n span.end();\n };\n const onClose = (): void => {\n cleanup();\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });\n span.end();\n };\n res.once('finish', onFinish);\n res.once('close', onClose);\n data._sentryCleanup = cleanup;\n }\n\n return span;\n}\n\nfunction getLayerType(layer: ExpressLayer): ExpressLayerType {\n if (layer.name === 'router') {\n return 'router';\n }\n // `bound dispatch` (v4) / `handle` — the route-dispatch layer created by `router.route()`.\n if (layer.name === 'bound dispatch' || layer.name === 'handle') {\n return 'request_handler';\n }\n return 'middleware';\n}\n\n/**\n * Whether a layer should be skipped per the `ignoreLayers`/`ignoreLayersType`\n * options. Matches `@sentry/core`'s Express `isLayerIgnored`: `ignoreLayersType`\n * filters by layer type, `ignoreLayers` matches the layer's name against\n * string/RegExp/predicate patterns (exact string match).\n */\nfunction isLayerIgnored(name: string, type: ExpressLayerType, options: ExpressIntegrationOptions): boolean {\n const { ignoreLayers, ignoreLayersType } = options;\n\n if (Array.isArray(ignoreLayersType) && ignoreLayersType.includes(type)) {\n return true;\n }\n\n if (!Array.isArray(ignoreLayers)) {\n return false;\n }\n\n try {\n return stringMatchesSomePattern(name, ignoreLayers, true);\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;AA8CA,MAAM,SAAS;AAKf,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAE1B,MAAM,0BAAkD;CACtD,YAAY;CACZ,iBAAiB;CACjB,QAAQ;AACV;AAEA,MAAM,aAAmB,CAAC;AAE1B,IAAI,kBAAkB;AAEtB,SAAgB,kBACd,SACA,gBACM;CACN,IAAI,iBACF;CAEF,kBAAkB;CAMlB,KAAK,MAAM,eAAe,CAAC,SAAS,kBAAkB,SAAS,eAAe,GAC5E,eAA2C,WAAW,CAAC,CAAC,UAAU;EAChE,OAAO;EACP,YAAY;EACZ,UAAU;EACV,OAAO;EACP,KAAK;CACP,CAAC;CAGH,KAAK,MAAM,eAAe,CAAC,SAAS,gBAAgB,SAAS,aAAa,GAAG;EAC3E,MAAM,UAAU,eAAqC,WAAW;EAEhE,yBAAyB,UAAS,SAAQ,gBAAgB,MAAM,OAAO,GAAG,EACxE,cAAc,OAAO,MAAM;GACzB,KAAK,iBAAiB;EACxB,EACF,CAAC;EAQD,QAAQ,UAAU;GAChB,OAAO;GACP,UAAU;GACV,KAAK;GACL,QAAO,SAAQ,kBAAkB,MAAM,QAAQ,iBAAiB;GAChE,aAAY,SAAQ;IAClB,qBAAqB,IAAI;IACzB,mBAAmB,IAAI;GACzB;EACF,CAAC;CACH;AACF;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,kBACd,MACA,mBACM;CACN,MAAM,QAAQ,KAAK;CAGnB,IAAI,CAAC,SAAS,UAAU,WAAW,UAAU,UAC3C;CAOF,MAAM,UAAU,KAAK,YAAY;CACjC,IAAI,SAAS;EACX,IAAI,sBAAsB,OAAO,GAC/B;EAEF,wBAAwB,OAAO;CACjC;CAEA,IAAI,sBAAsB,OACxB;CAGF,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MAAM,SAAS,oBAAoB,MAAM,SAAS,UACpD,OAAO;CAET,OAAO;AACT;;;;;;;AAQA,SAAS,eAAe,MAAc,MAAwB,SAA6C;CACzG,MAAM,EAAE,cAAc,qBAAqB;CAE3C,IAAI,MAAM,QAAQ,gBAAgB,KAAK,iBAAiB,SAAS,IAAI,GACnE,OAAO;CAGT,IAAI,CAAC,MAAM,QAAQ,YAAY,GAC7B,OAAO;CAGT,IAAI;EACF,OAAO,yBAAyB,MAAM,cAAc,IAAI;CAC1D,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"instrumentation.js","names":[],"sources":["../../../../src/integrations/express/instrumentation.ts"],"sourcesContent":["import type * as diagnosticsChannel from 'node:diagnostics_channel';\nimport { HTTP_ROUTE, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport { HANDLER, MIDDLEWARE, ROUTER } from '@sentry/conventions/op';\nimport type { Span } from '@sentry/core';\nimport {\n captureException,\n debug,\n getActiveSpan,\n getClient,\n getDefaultIsolationScope,\n getIsolationScope,\n hasSpanStreamingEnabled,\n REQUEST_HANDLER_SPAN_NAME_FALLBACK,\n ROUTER_SPAN_NAME_FALLBACK,\n SPAN_STATUS_ERROR,\n startInactiveSpan,\n stringMatchesSomePattern,\n withActiveSpan,\n} from '@sentry/core';\nimport { DEBUG_BUILD } from '../../debug-build';\nimport { CHANNELS } from '../../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../../tracing-channel';\nimport {\n getActualMatchedRoute,\n getConstructedRoute,\n getLayerPath,\n getLayerRegisteredPath,\n popLayerPath,\n pushLayerPath,\n setLayerRegisteredPath,\n} from './route';\nimport type {\n ExpressIntegrationOptions,\n ExpressLayer,\n ExpressLayerType,\n ExpressRequest,\n ExpressResponse,\n ExpressShouldHandleError,\n HandleChannelContext,\n MiddlewareError,\n RegistrationChannelContext,\n} from './types';\nimport { defaultShouldHandleError } from './utils';\nimport { isExpressErrorHandled, markExpressErrorHandled } from './error-handled';\nimport { setHttpServerSpanRouteAttribute } from '../../utils/setHttpServerSpanRouteAttribute';\n\nconst ORIGIN = 'auto.http.express';\n\n// `express.name`/`express.type` are Sentry-internal Express attributes (not part\n// of `@sentry/conventions`); kept in sync with `@sentry/core`'s OTel-derived\n// Express integration so the emitted spans are identical across both code paths.\nconst ATTR_EXPRESS_NAME = 'express.name';\nconst ATTR_EXPRESS_TYPE = 'express.type';\n\nconst EXPRESS_TYPE_TO_SPAN_OP: Record<string, string> = {\n middleware: MIDDLEWARE,\n request_handler: HANDLER,\n router: ROUTER,\n};\n\nconst NOOP = (): void => {};\n\nlet _isInstrumented = false;\n\nexport function instrumentExpress(\n options: ExpressIntegrationOptions,\n tracingChannel: typeof diagnosticsChannel.tracingChannel,\n): void {\n if (_isInstrumented) {\n return;\n }\n _isInstrumented = true;\n\n // Record each layer's registered path *pattern* as it is registered, so the\n // matched route can be reconstructed with its parameters intact at request\n // time. Only the `end` event matters (the layer is on the router's stack by\n // then); the others are required by the subscriber type, so no-op them.\n for (const channelName of [CHANNELS.EXPRESS_REGISTER, CHANNELS.ROUTER_REGISTER]) {\n tracingChannel<RegistrationChannelContext>(channelName).subscribe({\n start: NOOP,\n asyncStart: NOOP,\n asyncEnd: NOOP,\n error: NOOP,\n end: captureRegisteredLayerPath,\n });\n }\n\n for (const channelName of [CHANNELS.EXPRESS_HANDLE, CHANNELS.ROUTER_HANDLE]) {\n const channel = tracingChannel<HandleChannelContext>(channelName);\n\n bindTracingChannelToSpan(channel, data => getSpanForLayer(data, options), {\n beforeSpanEnd(_span, data) {\n data._sentryCleanup?.();\n },\n });\n\n // Pop the layer path and end the layer span when the layer hands off via\n // `next`. `asyncStart` fires when `next` is called and *before* the\n // downstream layer runs, so the per-request path chain reflects only the\n // current chain when each layer reconstructs its route, and each span covers\n // only its own layer. The `error` event captures throws at the layer level\n // (see `captureLayerError`), before any user error-handling middleware.\n channel.subscribe({\n start: NOOP,\n asyncEnd: NOOP,\n end: NOOP,\n error: data => captureLayerError(data, options.shouldHandleError),\n asyncStart: data => {\n popLayerPathForLayer(data);\n endLayerSpanOnNext(data);\n },\n });\n }\n}\n\n/**\n * Capture an error surfaced on a layer's `handle_request` channel — the throw\n * site, which runs before any user error-handling middleware.\n *\n * Each request's error is handled exactly once: the same error surfaces on every\n * parent layer's `error` event as it bubbles, and a user may also still call the\n * deprecated `setupExpressErrorHandler`. We mark the request the first time we\n * see it, so later layers and that middleware defer to this decision — the\n * integration is the single registered handler and its `shouldHandleError` wins.\n * This deliberately does not rely on `captureException`'s global dedup, which is\n * only set when an error is actually captured and so cannot express a\n * \"deliberately skipped\" decision (leaving the deprecated middleware free to\n * capture it and override `shouldHandleError`).\n *\n * `shouldHandleError` is the raw integration option: `false` disables capture\n * entirely, a function customizes the gate, and `undefined` falls back to\n * {@link defaultShouldHandleError}.\n */\nexport function captureLayerError(\n data: HandleChannelContext,\n shouldHandleError: ExpressShouldHandleError | undefined,\n): void {\n const error = data.error;\n\n // `next('route')` / `next('router')` are Express control-flow signals, not errors.\n if (!error || error === 'route' || error === 'router') {\n return;\n }\n\n // Take responsibility for this request's error exactly once (see the doc comment above). The marker\n // lives on the request — the same instance across every bubbling layer and the error middleware,\n // and always a mutable object, unlike the thrown value which may be frozen or a primitive. Mark\n // before the `shouldHandleError` gate so a \"skip\" decision also suppresses the deprecated middleware.\n const request = data.arguments?.[0] as ExpressRequest | undefined;\n if (request) {\n if (isExpressErrorHandled(request)) {\n return;\n }\n markExpressErrorHandled(request);\n }\n\n if (shouldHandleError === false) {\n return;\n }\n\n if (!(shouldHandleError ?? defaultShouldHandleError)(error as MiddlewareError)) {\n return;\n }\n\n const capture = (): string =>\n captureException(error, {\n mechanism: {\n type: 'auto.http.express',\n handled: false,\n },\n });\n\n // The channel's `error` event runs outside the layer span's async context, so\n // re-activate the bound span (when present) to parent the error event to the\n // request's trace instead of capturing it context-free.\n if (data._sentrySpan) {\n withActiveSpan(data._sentrySpan, capture);\n } else {\n capture();\n }\n}\n\n/** Record the freshly-registered layer's path pattern from a `route`/`use` call. */\nfunction captureRegisteredLayerPath(data: RegistrationChannelContext): void {\n const stack = data.self?.stack;\n if (!Array.isArray(stack)) {\n return;\n }\n const layer = stack[stack.length - 1];\n if (layer) {\n setLayerRegisteredPath(layer, getLayerPath(data.arguments ?? []));\n }\n}\n\n/** Pop the path a layer pushed once it hands control onward via `next`. */\nfunction popLayerPathForLayer(data: HandleChannelContext): void {\n if (!data._sentryStoredLayer) {\n return;\n }\n // Clear the marker first so a layer that (incorrectly) calls `next` more than\n // once can't pop again and take a parent's entry off the stack with it.\n data._sentryStoredLayer = false;\n const req = data.arguments?.[0] as ExpressRequest | undefined;\n if (req) {\n popLayerPath(req);\n }\n}\n\n/**\n * End a layer's span once it hands control onward via `next`.\n *\n * The tracing-channel helper would otherwise end it on `asyncEnd`, which only\n * fires once `next` *returns*. Express runs the rest of the chain synchronously\n * inside `next`, so that would keep every layer on the synchronous chain open\n * (each holding a response `finish` listener) until the whole chain unwinds,\n * and inflate each span with the downstream layers' synchronous work. The\n * helper's later `asyncEnd` is then a no-op, since `span.end()` is idempotent.\n */\nfunction endLayerSpanOnNext(data: HandleChannelContext): void {\n const span = data._sentrySpan;\n if (!span) {\n return;\n }\n data._sentryCleanup?.();\n span.end();\n}\n\n/**\n * Open a span for one layer invocation. Returns `undefined` to opt the layer\n * out (error handlers, or a layer with no active parent trace) — the helper\n * then leaves the active context untouched.\n */\nfunction getSpanForLayer(data: HandleChannelContext, options: ExpressIntegrationOptions): Span | undefined {\n const layer = data.self;\n const args = data.arguments;\n if (!layer || !Array.isArray(args)) {\n return undefined;\n }\n\n // Express only treats a 4-arg handler as an error handler and skips it in\n // the normal request pipeline; match the OTel integration and don't trace it.\n if (layer.handle?.length === 4) {\n return undefined;\n }\n\n // A Route dispatches to its handlers via the same `handle_request` method,\n // but those inner layers already run inside the route-dispatch layer's\n // `request_handler` span. They carry `.method` (and no `.route`); skip them\n // so we emit one span per route, matching the OTel Express integration.\n if (layer.method && !layer.route) {\n return undefined;\n }\n\n const req = args[0] as ExpressRequest | undefined;\n const res = args[1] as ExpressResponse | undefined;\n if (!req) {\n return undefined;\n }\n\n // No active parent span means this request is being ignored (unsampled /\n // filtered), so don't open a span\n if (!getActiveSpan()) {\n return undefined;\n }\n\n const type = getLayerType(layer);\n\n // Push this layer's registered path onto the request's chain so a\n // `request_handler` can reconstruct the full route with parameters intact\n // (`req.baseUrl` only exposes the *resolved* mount prefix). The matching pop\n // happens on `asyncStart` when the layer hands off via `next`.\n const registeredPath = getLayerRegisteredPath(layer) ?? getMatchedLayerPath(layer);\n if (registeredPath != null) {\n pushLayerPath(req, registeredPath);\n data._sentryStoredLayer = true;\n }\n\n // `constructedRoute` (the full registered pattern) names the span/transaction;\n // `matchedRoute` (validated against the request URL) is the `http.route`.\n // Computed for every layer type (not just `request_handler`) so routes served\n // by mounted middleware (`app.use('/trpc', handler)`) still propagate their\n // path to the root `http.server` span — mirroring the OTel Express integration,\n // which resolves the route on every layer. Without this, such transactions keep\n // the raw URL name (e.g. `GET /trpc/foo` instead of `GET /trpc`).\n const constructedRoute = getConstructedRoute(req);\n const matchedRoute = constructedRoute != null ? getActualMatchedRoute(req, constructedRoute) : undefined;\n\n const name =\n type === 'request_handler'\n ? constructedRoute || 'request handler'\n : type === 'router'\n ? (layer.path ?? '/')\n : (layer.name ?? '<anonymous>');\n\n // Propagate the route to the root `http.server` span *before* the ignore\n // check, so the transaction is still named even when the layer's own span is\n // ignored — matches the OTel Express integration's `onRouteResolved` timing.\n if (matchedRoute) {\n setHttpServerSpanRouteAttribute(matchedRoute);\n }\n\n if (type === 'request_handler' && constructedRoute) {\n const isolationScope = getIsolationScope();\n if (isolationScope !== getDefaultIsolationScope()) {\n const method = typeof req.method === 'string' ? req.method.toUpperCase() : 'GET';\n isolationScope.setTransactionName(`${method} ${constructedRoute}`);\n } else {\n DEBUG_BUILD &&\n debug.warn(\n '[instrumentation:express] Isolation scope is still default isolation scope - skipping transaction name',\n );\n }\n }\n\n // Honor `ignoreLayers`/`ignoreLayersType`: skip the span for matching layers.\n // We intentionally do NOT pop the pushed path here (unlike OTel Express, which\n // pops on ignore): the path is still popped on `asyncStart` when the layer\n // calls `next`, so a following sibling isn't polluted, while an ignored\n // *router* keeps its mount prefix on the stack for the sub-stack it dispatches\n // — so routes under an ignored router stay correct. The only entries that\n // never pop come from layers that end the response without `next()`, and those\n // sit on a per-request store that is discarded when the request ends.\n if (isLayerIgnored(name, type, options)) {\n return undefined;\n }\n\n const client = getClient();\n // With span streaming, span names have to be low cardinality, so router\n // and request handler spans are named after their route. A route that did\n // not validate against the request URL can describe a different request,\n // so those spans take the static fallback instead.\n const isStreamedSpan = !!client && hasSpanStreamingEnabled(client);\n const isStreamedRouterSpan = isStreamedSpan && type === 'router';\n const isStreamedRequestHandlerSpan = isStreamedSpan && type === 'request_handler';\n\n const span = startInactiveSpan({\n name: isStreamedRouterSpan\n ? matchedRoute || ROUTER_SPAN_NAME_FALLBACK\n : isStreamedRequestHandlerSpan\n ? matchedRoute || REQUEST_HANDLER_SPAN_NAME_FALLBACK\n : name,\n attributes: {\n [SENTRY_ORIGIN]: ORIGIN,\n [SENTRY_OP]: EXPRESS_TYPE_TO_SPAN_OP[type],\n [ATTR_EXPRESS_NAME]: name,\n [ATTR_EXPRESS_TYPE]: type,\n [HTTP_ROUTE]: matchedRoute,\n },\n });\n\n // A layer that sends the response (route handlers, typically) never calls\n // `next`, so the channel's `asyncStart` never fires. End on the response's\n // `finish` in that case. When `next` *is* called, `endLayerSpanOnNext` ends\n // the span and removes these now-redundant listeners.\n // `finish` never fires when the client aborts, so also end on `close`, which\n // is when the `http.server` span ends. Otherwise the span and its subtree\n // would be dropped from the transaction.\n if (res && typeof res.once === 'function') {\n const cleanup = (): void => {\n res.removeListener('finish', onFinish);\n res.removeListener('close', onClose);\n };\n const onFinish = (): void => {\n cleanup();\n span.end();\n };\n const onClose = (): void => {\n cleanup();\n span.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });\n span.end();\n };\n res.once('finish', onFinish);\n res.once('close', onClose);\n data._sentryCleanup = cleanup;\n }\n\n return span;\n}\n\n/**\n * The path of a matched layer for which no registration event recorded a path. That is the case when the events\n * arrive after the registration calls: Cloudflare delivers the events of calls at module scope with the first\n * request.\n */\nfunction getMatchedLayerPath(layer: ExpressLayer): string | undefined {\n if (layer.route) {\n return getLayerPath([layer.route.path]);\n }\n // A mount path without parameters is equal to the part of the URL that the layer matched.\n return layer.keys?.length ? undefined : layer.path || undefined;\n}\n\nfunction getLayerType(layer: ExpressLayer): ExpressLayerType {\n if (layer.name === 'router') {\n return 'router';\n }\n // `bound dispatch` (v4) / `handle` — the route-dispatch layer created by `router.route()`.\n if (layer.name === 'bound dispatch' || layer.name === 'handle') {\n return 'request_handler';\n }\n return 'middleware';\n}\n\n/**\n * Whether a layer should be skipped per the `ignoreLayers`/`ignoreLayersType`\n * options. Matches `@sentry/core`'s Express `isLayerIgnored`: `ignoreLayersType`\n * filters by layer type, `ignoreLayers` matches the layer's name against\n * string/RegExp/predicate patterns (exact string match).\n */\nfunction isLayerIgnored(name: string, type: ExpressLayerType, options: ExpressIntegrationOptions): boolean {\n const { ignoreLayers, ignoreLayersType } = options;\n\n if (Array.isArray(ignoreLayersType) && ignoreLayersType.includes(type)) {\n return true;\n }\n\n if (!Array.isArray(ignoreLayers)) {\n return false;\n }\n\n try {\n return stringMatchesSomePattern(name, ignoreLayers, true);\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;AA8CA,MAAM,SAAS;AAKf,MAAM,oBAAoB;AAC1B,MAAM,oBAAoB;AAE1B,MAAM,0BAAkD;CACtD,YAAY;CACZ,iBAAiB;CACjB,QAAQ;AACV;AAEA,MAAM,aAAmB,CAAC;AAE1B,IAAI,kBAAkB;AAEtB,SAAgB,kBACd,SACA,gBACM;CACN,IAAI,iBACF;CAEF,kBAAkB;CAMlB,KAAK,MAAM,eAAe,CAAC,SAAS,kBAAkB,SAAS,eAAe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AI;EACF,OAAO,yBAAyB,MAAM,cAAc,IAAI;CAC1D,QAAQ;EACN,OAAO;CACT;AACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
-
import { getGenAiSpanOp, markCancelledIfAborted,
|
|
3
|
-
import {
|
|
2
|
+
import { getGenAiSpanOp, markCancelledIfAborted, resolveGenAiCallRecording } from "../ai/core/utils.js";
|
|
3
|
+
import { runGenAiSpanEnd, runGenAiSpanStart } from "../ai/core/span-hooks.js";
|
|
4
|
+
import { addPrivateRequestAttributes, addResponseAttributes, extractRequestAttributes, getAbortSignal, getCallAbortSignal, resolveChatParams } from "../ai/google-genai/index.js";
|
|
4
5
|
import { shouldSkipAiProviderSpan } from "../ai/pi-ai/providers.js";
|
|
5
6
|
import { instrumentStream } from "../ai/google-genai/streaming.js";
|
|
6
7
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
@@ -24,6 +25,10 @@ const INSTRUMENTED_CHANNELS = [
|
|
|
24
25
|
{
|
|
25
26
|
channel: CHANNELS.GOOGLE_GENAI_CHAT,
|
|
26
27
|
operation: "chat"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
channel: CHANNELS.GOOGLE_GENAI_DECIDE,
|
|
31
|
+
operation: "decide"
|
|
27
32
|
}
|
|
28
33
|
];
|
|
29
34
|
const _googleGenAIIntegration = ((options = {}) => {
|
|
@@ -39,11 +44,12 @@ function instrumentGoogleGenai(options) {
|
|
|
39
44
|
beforeSpanEnd: (span, data) => {
|
|
40
45
|
if ("error" in data) {
|
|
41
46
|
const params = resolveChatParams(operation, data.arguments?.[0], data.self);
|
|
42
|
-
markCancelledIfAborted(span,
|
|
47
|
+
markCancelledIfAborted(span, getCallAbortSignal(operation, params, data.arguments?.[1]));
|
|
43
48
|
}
|
|
44
|
-
if (operation !== "embeddings") addResponseAttributes(span, data.result,
|
|
49
|
+
if (operation !== "embeddings") addResponseAttributes(span, data.result, !!data._sentryRecordOutputs, operation);
|
|
50
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
45
51
|
},
|
|
46
|
-
deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, operation
|
|
52
|
+
deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, operation)
|
|
47
53
|
});
|
|
48
54
|
}
|
|
49
55
|
/**
|
|
@@ -59,9 +65,14 @@ function createGenAiSpan(data, operation, options) {
|
|
|
59
65
|
if (origin === ORIGIN && op === "gen_ai.chat") return;
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
|
-
const
|
|
63
|
-
const params = resolveChatParams(operation,
|
|
64
|
-
const
|
|
68
|
+
const request = (data.arguments ?? [])[0];
|
|
69
|
+
const params = resolveChatParams(operation, request, data.self);
|
|
70
|
+
const call = {
|
|
71
|
+
operation,
|
|
72
|
+
request
|
|
73
|
+
};
|
|
74
|
+
const { recordInputs, recordOutputs } = resolveGenAiCallRecording(options, call);
|
|
75
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
65
76
|
const attributes = extractRequestAttributes(operation, params, data.self, recordInputs);
|
|
66
77
|
const model = attributes[GEN_AI_REQUEST_MODEL] || "unknown";
|
|
67
78
|
attributes[SENTRY_ORIGIN] = ORIGIN;
|
|
@@ -72,6 +83,8 @@ function createGenAiSpan(data, operation, options) {
|
|
|
72
83
|
attributes
|
|
73
84
|
});
|
|
74
85
|
if (recordInputs && params) addPrivateRequestAttributes(span, params, operation);
|
|
86
|
+
runGenAiSpanStart(options, span, call);
|
|
87
|
+
data._sentryOnSpanEnd = (result) => runGenAiSpanEnd(options, span, call, result);
|
|
75
88
|
return span;
|
|
76
89
|
}
|
|
77
90
|
function isAsyncIterable(value) {
|
|
@@ -82,22 +95,21 @@ function isAsyncIterable(value) {
|
|
|
82
95
|
* For a stream we patch `result[Symbol.asyncIterator]` in place so `instrumentStream` ends the
|
|
83
96
|
* span when iteration finishes.
|
|
84
97
|
*/
|
|
85
|
-
function wrapStreamResult(span, data, operation
|
|
98
|
+
function wrapStreamResult(span, data, operation) {
|
|
86
99
|
const result = data.result;
|
|
87
100
|
if (!isAsyncIterable(result)) return false;
|
|
88
|
-
const { recordOutputs } = resolveAIRecordingOptions(options);
|
|
89
101
|
const iterate = result[Symbol.asyncIterator].bind(result);
|
|
90
102
|
const params = resolveChatParams(operation, data.arguments?.[0], data.self);
|
|
91
|
-
const instrumented = instrumentStream({ [Symbol.asyncIterator]: iterate }, span,
|
|
103
|
+
const instrumented = instrumentStream({ [Symbol.asyncIterator]: iterate }, span, !!data._sentryRecordOutputs, getAbortSignal(params), data._sentryOnSpanEnd);
|
|
92
104
|
result[Symbol.asyncIterator] = () => instrumented;
|
|
93
105
|
return true;
|
|
94
106
|
}
|
|
95
107
|
/**
|
|
96
108
|
* Diagnostics-channel-based Google GenAI integration. Subscribes to the
|
|
97
109
|
* `orchestrion:@google/genai:*` diagnostics_channels injected into the SDK's `Models`
|
|
98
|
-
* (`generateContent`/`generateContentStream`/`embedContent`)
|
|
99
|
-
* (`sendMessage`/`sendMessageStream`) methods, so it requires the Sentry
|
|
100
|
-
* bundler plugin.
|
|
110
|
+
* (`generateContent`/`generateContentStream`/`embedContent`), `Chat`
|
|
111
|
+
* (`sendMessage`/`sendMessageStream`) and decisions (`create`) methods, so it requires the Sentry
|
|
112
|
+
* runtime hook or bundler plugin.
|
|
101
113
|
*/
|
|
102
114
|
const googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);
|
|
103
115
|
export { googleGenAIIntegration };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-genai.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/google-genai.ts"],"sourcesContent":["import { GEN_AI_REQUEST_MODEL, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n defineIntegration,\n getActiveSpan,\n getClient,\n hasSpanStreamingEnabled,\n spanToJSON,\n startInactiveSpan,\n} from '@sentry/core';\nimport { getGenAiSpanOp, markCancelledIfAborted,
|
|
1
|
+
{"version":3,"file":"google-genai.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/google-genai.ts"],"sourcesContent":["import { GEN_AI_REQUEST_MODEL, SENTRY_OP, SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span } from '@sentry/core';\nimport {\n defineIntegration,\n getActiveSpan,\n getClient,\n hasSpanStreamingEnabled,\n spanToJSON,\n startInactiveSpan,\n} from '@sentry/core';\nimport { getGenAiSpanOp, markCancelledIfAborted, resolveGenAiCallRecording } from '../ai/core/utils';\nimport { type GenAiSpanResult, runGenAiSpanEnd, runGenAiSpanStart } from '../ai/core/span-hooks';\nimport {\n addPrivateRequestAttributes,\n addResponseAttributes,\n extractRequestAttributes,\n getAbortSignal,\n getCallAbortSignal,\n resolveChatParams,\n} from '../ai/google-genai';\nimport { shouldSkipAiProviderSpan } from '../ai/pi-ai/providers';\nimport { instrumentStream } from '../ai/google-genai/streaming';\nimport type { GoogleGenAICallInfo, GoogleGenAIOptions, GoogleGenAIResponse } from '../ai/google-genai/types';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\nimport { googleGenAiModuleNames } from '../orchestrion/config/google-genai';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\n\n// Same name as the OTel integration by design, so the OTel 'Google_GenAI'\n// integration is deduplicated out of the default set.\nconst INTEGRATION_NAME = 'Google_GenAI' as const;\n\nconst ORIGIN = 'auto.ai.google_genai';\n\n// The recording decision is made once, when the span starts, in the caller's async context.\ntype GoogleGenAIChannelContext = OrchestrionChannelContext & {\n _sentryRecordOutputs?: boolean;\n _sentryOnSpanEnd?: (result: GenAiSpanResult<unknown>) => void;\n};\n\n// Each instrumented method maps to the gen_ai operation its span reports.\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.GOOGLE_GENAI_GENERATE_CONTENT, operation: 'generate_content' },\n { channel: CHANNELS.GOOGLE_GENAI_EMBED_CONTENT, operation: 'embeddings' },\n { channel: CHANNELS.GOOGLE_GENAI_CHAT, operation: 'chat' },\n { channel: CHANNELS.GOOGLE_GENAI_DECIDE, operation: 'decide' },\n] as const;\n\nconst _googleGenAIIntegration = ((options: GoogleGenAIOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, googleGenAiModuleNames, instrumentGoogleGenai, [options]);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction instrumentGoogleGenai(options: GoogleGenAIOptions): void {\n for (const { channel, operation } of INSTRUMENTED_CHANNELS) {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<GoogleGenAIChannelContext>(channel),\n data => createGenAiSpan(data, operation, options),\n {\n beforeSpanEnd: (span, data) => {\n if ('error' in data) {\n const params = resolveChatParams(\n operation,\n data.arguments?.[0] as Record<string, unknown> | undefined,\n data.self,\n );\n markCancelledIfAborted(span, getCallAbortSignal(operation, params, data.arguments?.[1]));\n }\n // Embeddings responses carry no content attributes.\n if (operation !== 'embeddings') {\n addResponseAttributes(span, data.result as GoogleGenAIResponse, !!data._sentryRecordOutputs, operation);\n }\n data._sentryOnSpanEnd?.('error' in data ? { error: data.error } : { response: data.result });\n },\n deferSpanEnd: ({ span, data }) => wrapStreamResult(span, data, operation),\n },\n );\n }\n}\n\n/**\n * Build the span for an instrumented call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(\n data: GoogleGenAIChannelContext,\n operation: string,\n options: GoogleGenAIOptions,\n): Span | undefined {\n if (shouldSkipAiProviderSpan(INTEGRATION_NAME)) {\n return undefined;\n }\n\n // `chat.sendMessage()`/`sendMessageStream()` internally call `Models.generateContent(Stream)`, which\n // publishes the `generate-content` channel while the chat span is active. Skip that nested event so a\n // chat call yields a single `gen_ai.chat` span instead of a chat span wrapping a generate_content one.\n if (operation !== 'chat') {\n const activeSpan = getActiveSpan();\n if (activeSpan) {\n const {\n attributes: { [SENTRY_OP]: op, [SENTRY_ORIGIN]: origin },\n } = spanToJSON(activeSpan);\n if (origin === ORIGIN && op === 'gen_ai.chat') {\n return undefined;\n }\n }\n }\n\n const args = data.arguments ?? [];\n // `chat.sendMessage()` carries no config of its own unless the caller passes one, so recover the\n // one `chats.create()` left on the chat instance that the transform stashed in `data.self`.\n const request = args[0] as Record<string, unknown> | undefined;\n const params = resolveChatParams(operation, request, data.self);\n\n const call: GoogleGenAICallInfo = { operation, request };\n const { recordInputs, recordOutputs } = resolveGenAiCallRecording(options, call);\n data._sentryRecordOutputs = recordOutputs;\n\n const attributes = extractRequestAttributes(operation, params, data.self, recordInputs);\n const model = (attributes[GEN_AI_REQUEST_MODEL] as string) || 'unknown';\n attributes[SENTRY_ORIGIN] = ORIGIN;\n const client = getClient();\n\n const span = startInactiveSpan({\n // With span streaming, omit the `'unknown'` model sentinel so the name stays low-cardinality.\n name: model !== 'unknown' || !(client && hasSpanStreamingEnabled(client)) ? `${operation} ${model}` : operation,\n op: getGenAiSpanOp(operation),\n attributes,\n });\n\n if (recordInputs && params) {\n addPrivateRequestAttributes(span, params, operation);\n }\n\n runGenAiSpanStart(options, span, call);\n data._sentryOnSpanEnd = result => runGenAiSpanEnd(options, span, call, result);\n\n return span;\n}\n\ntype AsyncIterableStream = { [Symbol.asyncIterator]: () => AsyncIterator<unknown> };\n\nfunction isAsyncIterable(value: unknown): value is AsyncIterableStream {\n return !!value && typeof (value as AsyncIterableStream)[Symbol.asyncIterator] === 'function';\n}\n\n/**\n * Only the streaming methods (`generateContentStream`/`sendMessageStream`) resolve to an async iterable.\n * For a stream we patch `result[Symbol.asyncIterator]` in place so `instrumentStream` ends the\n * span when iteration finishes.\n */\nfunction wrapStreamResult(span: Span, data: GoogleGenAIChannelContext, operation: string): boolean {\n const result = data.result;\n if (!isAsyncIterable(result)) {\n return false;\n }\n\n const iterate = result[Symbol.asyncIterator].bind(result);\n const params = resolveChatParams(operation, data.arguments?.[0] as Record<string, unknown> | undefined, data.self);\n const instrumented = instrumentStream(\n { [Symbol.asyncIterator]: iterate },\n span,\n !!data._sentryRecordOutputs,\n getAbortSignal(params),\n data._sentryOnSpanEnd,\n );\n result[Symbol.asyncIterator] = () => instrumented;\n\n return true;\n}\n\n/**\n * Diagnostics-channel-based Google GenAI integration. Subscribes to the\n * `orchestrion:@google/genai:*` diagnostics_channels injected into the SDK's `Models`\n * (`generateContent`/`generateContentStream`/`embedContent`), `Chat`\n * (`sendMessage`/`sendMessageStream`) and decisions (`create`) methods, so it requires the Sentry\n * runtime hook or bundler plugin.\n */\nexport const googleGenAIIntegration = defineIntegration(_googleGenAIIntegration);\n"],"mappings":";;;;;;;;;;;;;AAgCA,MAAM,mBAAmB;AAEzB,MAAM,SAAS;AASf,MAAM,wBAAwB;CAC5B;EAAE,SAAS,SAAS;EAA+B,WAAW;CAAmB;CACjF;EAAE,SAAS,SAAS;EAA4B,WAAW;CAAa;CACxE;EAAE,SAAS,SAAS;EAAmB,WAAW;CAAO;CACzD;EAAE,SAAS,SAAS;EAAqB,WAAW;CAAS;AAC/D;AAEA,MAAM,4BAA4B,UAA8B,CAAC,MAAM;CACrE,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GACZ,iCAAiC,QAAQ,wBAAwB,uBAAuB,CAAC,OAAO,CAAC;EACnG;CACF;AACF;AAEA,SAAS,sBAAsB,SAAmC;CAChE,KAAK,MAAM,EAAE,SAAS,eAAe,uBACnC,yBACEA,eAA6D,OAAO,IACpE,SAAQ,gBAAgB,MAAM,WAAW,OAAO,GAChD;EACE,gBAAgB,MAAM,SAAS;GAC7B,IAAI,WAAW,MAAM;IACnB,MAAM,SAAS,kBACb,WACA,KAAK,YAAY,IACjB,KAAK,IACP;IACA,uBAAuB,MA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AO;AACT;AAIA,SAAS,gBAAgB,OAA8C;CACrE,OAAO,CAAC,CAAC,SAAS,OAAQ,MAA8B,OAAO,mBAAmB;AACpF;;;;;;AAOA,SAAS,iBAAiB,MAAY,MAAiC,WAA4B;CACjG,MAAM,SAAS,KAAK;CACpB,IAAI,CAAC,gBAAgB,MAAM,GACzB,OAAO;CAGT,MAAM,UAAU,OAAO,OAAO,cAAc,CAAC,KAAK,MAAM;CACxD,MAAM,SAAS,kBAAkB,WAAW,KAAK,YAAY,IAA2C,KAAK,IAAI;CACjH,MAAM,eAAe,iBACnB,GAAG,OAAO,gBAAgB,QAAQ,GAClC,MACA,CAAC,CAAC,KAAK,sBACP,eAAe,MAAM,GACrB,KAAK,gBACP;CACA,OAAO,OAAO,uBAAuB;CAErC,OAAO;AACT;;;;;;;;AASA,MAAa,yBAAyB,kBAAkB,uBAAuB"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
-
import { resolveAIRecordingOptions } from "../ai/core/utils.js";
|
|
3
2
|
import { createLangChainCallbackHandler } from "../ai/langchain/index.js";
|
|
4
3
|
import { instrumentCompiledGraph, isInsideManualLangGraphInstrumentation } from "../ai/langgraph/index.js";
|
|
5
4
|
import { LANGGRAPH_INTEGRATION_NAME } from "../ai/langgraph/constants.js";
|
|
6
|
-
import { extractAgentNameFromParams, extractLLMFromParams, wrapToolsWithSpans } from "../ai/langgraph/utils.js";
|
|
5
|
+
import { extractAgentNameFromParams, extractLLMFromParams, getBooleanRecordingOptions, wrapToolsWithSpans } from "../ai/langgraph/utils.js";
|
|
7
6
|
import { DEBUG_BUILD } from "../debug-build.js";
|
|
8
7
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
9
8
|
import { langgraphModuleNames } from "../orchestrion/config/langgraph.js";
|
|
@@ -21,12 +20,11 @@ const _langGraphIntegration = ((options = {}) => {
|
|
|
21
20
|
};
|
|
22
21
|
});
|
|
23
22
|
function instrumentLanggraph(options) {
|
|
24
|
-
const
|
|
25
|
-
const sentryHandler = createLangChainCallbackHandler(resolvedOptions);
|
|
23
|
+
const sentryHandler = createLangChainCallbackHandler(getBooleanRecordingOptions(options));
|
|
26
24
|
tracingChannel(CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE).end.subscribe((message) => {
|
|
27
25
|
if (insideCreateReactAgent || isInsideManualLangGraphInstrumentation()) return;
|
|
28
26
|
const { arguments: args, result } = message;
|
|
29
|
-
instrumentCompiledGraph(result, getFirstArgObject(args) ?? {},
|
|
27
|
+
instrumentCompiledGraph(result, getFirstArgObject(args) ?? {}, options, null, sentryHandler);
|
|
30
28
|
});
|
|
31
29
|
const reactAgentChannel = tracingChannel(CHANNELS.LANGGRAPH_CREATE_REACT_AGENT);
|
|
32
30
|
reactAgentChannel.start.subscribe((message) => {
|
|
@@ -34,7 +32,7 @@ function instrumentLanggraph(options) {
|
|
|
34
32
|
try {
|
|
35
33
|
const { arguments: args } = message;
|
|
36
34
|
const params = getFirstArgObject(args);
|
|
37
|
-
if (params && Array.isArray(params.tools) && params.tools.length > 0) wrapToolsWithSpans(params.tools,
|
|
35
|
+
if (params && Array.isArray(params.tools) && params.tools.length > 0) wrapToolsWithSpans(params.tools, options, extractAgentNameFromParams(args) ?? void 0);
|
|
38
36
|
} catch (error) {
|
|
39
37
|
DEBUG_BUILD && debug.error("[instrumentation:langgraph] failed to wrap createReactAgent tools", error);
|
|
40
38
|
}
|
|
@@ -44,7 +42,7 @@ function instrumentLanggraph(options) {
|
|
|
44
42
|
if (isInsideManualLangGraphInstrumentation()) return;
|
|
45
43
|
const { arguments: args, result } = message;
|
|
46
44
|
const agentName = extractAgentNameFromParams(args) ?? void 0;
|
|
47
|
-
instrumentCompiledGraph(result, agentName ? { name: agentName } : {},
|
|
45
|
+
instrumentCompiledGraph(result, agentName ? { name: agentName } : {}, options, extractLLMFromParams(args), sentryHandler);
|
|
48
46
|
});
|
|
49
47
|
reactAgentChannel.error.subscribe(() => {
|
|
50
48
|
insideCreateReactAgent = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langgraph.js","names":["diagnosticsChannel\n .tracingChannel","diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/langgraph.ts"],"sourcesContent":["import * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, isObjectLike } from '@sentry/core';\nimport {
|
|
1
|
+
{"version":3,"file":"langgraph.js","names":["diagnosticsChannel\n .tracingChannel","diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/langgraph.ts"],"sourcesContent":["import * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn } from '@sentry/core';\nimport { debug, defineIntegration, isObjectLike } from '@sentry/core';\nimport { createLangChainCallbackHandler } from '../ai/langchain';\nimport { instrumentCompiledGraph, isInsideManualLangGraphInstrumentation } from '../ai/langgraph';\nimport { LANGGRAPH_INTEGRATION_NAME } from '../ai/langgraph/constants';\nimport type { LangGraphOptions } from '../ai/langgraph/types';\nimport {\n extractAgentNameFromParams,\n extractLLMFromParams,\n getBooleanRecordingOptions,\n wrapToolsWithSpans,\n} from '../ai/langgraph/utils';\nimport { DEBUG_BUILD } from '../debug-build';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { langgraphModuleNames } from '../orchestrion/config/langgraph';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\n\n// Same name as the OTel integration by design, so the OTel 'LangGraph' integration is\n// deduplicated out of the default set.\nconst INTEGRATION_NAME = LANGGRAPH_INTEGRATION_NAME;\n\n// `createReactAgent` compiles a `StateGraph` internally. When set, the compile subscriber skips that nested\n// graph, so the createReactAgent handler wraps it with the agent's name and model instead.\nlet insideCreateReactAgent = false;\n\nconst _langGraphIntegration = ((options: LangGraphOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n // Nothing here opens a span at subscribe time, so a missing async-context\n // binding must never defer the subscription.\n invokeOrchestrionInstrumentation(client, langgraphModuleNames, instrumentLanggraph, [options], {\n requiresTracingChannelBinding: false,\n });\n },\n };\n}) satisfies IntegrationFn;\n\nfunction instrumentLanggraph(options: LangGraphOptions): void {\n const sentryHandler = createLangChainCallbackHandler(getBooleanRecordingOptions(options));\n\n // StateGraph.compile returns synchronously; wrap the returned graph's `invoke` and `stream` at `end`.\n diagnosticsChannel\n .tracingChannel<OrchestrionChannelContext>(CHANNELS.LANGGRAPH_STATE_GRAPH_COMPILE)\n .end.subscribe(message => {\n if (insideCreateReactAgent || isInsideManualLangGraphInstrumentation()) {\n return;\n }\n const { arguments: args, result } = message as OrchestrionChannelContext;\n instrumentCompiledGraph(result, getFirstArgObject(args) ?? {}, options, null, sentryHandler);\n });\n\n // createReactAgent only wraps tools and the returned graph's `invoke` and `stream`. Tools are wrapped at\n // `start` (before the agent runs), the graph at `end`.\n const reactAgentChannel = diagnosticsChannel.tracingChannel<OrchestrionChannelContext>(\n CHANNELS.LANGGRAPH_CREATE_REACT_AGENT,\n );\n reactAgentChannel.start.subscribe(message => {\n // `createReactAgent` runs synchronously and compiles a `StateGraph` internally, so the flag\n // must be on for the duration and off by `end`. It's set here (never in a branch that can\n // throw) and cleared in both `end` and `error`, so it can neither stick on across calls nor\n // stay off during this call's nested compile. Tool wrapping is guarded for the same reason.\n insideCreateReactAgent = true;\n try {\n const { arguments: args } = message as OrchestrionChannelContext;\n const params = getFirstArgObject(args);\n if (params && Array.isArray(params.tools) && params.tools.length > 0) {\n wrapToolsWithSpans(params.tools, options, extractAgentNameFromParams(args) ?? undefined);\n }\n } catch (error) {\n DEBUG_BUILD && debug.error('[instrumentation:langgraph] failed to wrap createReactAgent tools', error);\n }\n });\n reactAgentChannel.end.subscribe(message => {\n insideCreateReactAgent = false;\n if (isInsideManualLangGraphInstrumentation()) {\n return;\n }\n const { arguments: args, result } = message as OrchestrionChannelContext;\n const agentName = extractAgentNameFromParams(args) ?? undefined;\n const compileOptions = agentName ? { name: agentName } : {};\n instrumentCompiledGraph(result, compileOptions, options, extractLLMFromParams(args), sentryHandler);\n });\n // Make sure a thrown `createReactAgent` doesn't leave the suppression flag stuck on.\n reactAgentChannel.error.subscribe(() => {\n insideCreateReactAgent = false;\n });\n}\n\nfunction getFirstArgObject(args: unknown[] | undefined): Record<string, unknown> | undefined {\n const first = (args ?? [])[0];\n\n return isObjectLike(first) ? first : undefined;\n}\n\n/**\n * Diagnostics-channel-based LangGraph integration. Subscribes to the diagnostics_channels\n * injected into `@langchain/langgraph`'s `StateGraph.compile` and `createReactAgent`, so it requires\n * the Sentry runtime hook or bundler plugin.\n */\nexport const langGraphIntegration = defineIntegration(_langGraphIntegration);\n"],"mappings":";;;;;;;;;;;AAqBA,MAAM,mBAAmB;AAIzB,IAAI,yBAAyB;AAE7B,MAAM,0BAA0B,UAA4B,CAAC,MAAM;CACjE,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GAGZ,iCAAiC,QAAQ,sBAAsB,qBAAqB,CAAC,OAAO,GAAG,EAC7F,+BAA+B,MACjC,CAAC;EACH;CACF;AACF;AAEA,SAAS,oBAAoB,SAAiC;CAC5D,MAAM,gBAAgB,+BAA+B,2BAA2B,OAAO,CAAC;CAGxFA,eAC6C,SAAS,6BAA6B,CAAC,CACjF,IAAI,WAAU,YAAW;EACxB,IAAI,0BAA0B,uCAAuC,GACnE;EAEF,MAAM,EAAE,WAAW,MAAM,WAAW;EACpC,wBAAwB,QAAQ,kBAAkB,IAAI,KAAK,CAAC,GAAG,SAAS,MAAM,aAAa;CAC7F,CAAC;CAIH,MAAM,oBAAoBC,eACxB,SAAS,4BACX;CACA,kBAAkB,MAAM,WAAU,YAAW;EAK3C,yBAAyB;EACzB,IAAI;GACF,MAAM,EAAE,WAAW,SAAS;GAC5B,MAAM,SAAS,kBAAkB,IAAI;GACrC,IAAI,UAAU,MAAM,QAAQ,OAAO,KAAK,KAAK,OAAO,MAAM,SAAS,GACjE,mBAAmB,OAAO,OAAO,SAAS,2BAA2B,IAAI,KAAK,KAAA,CAAS;EAE3F,SAAS,OAAO;GACd,eAAe,MAAM,MAAM,qEAAqE,KAAK;EACvG;CACF,CAAC;CACD,kBAAkB,IAAI,WAAU,YAAW;EACzC,yBAAyB;EACzB,IAAI,uCAAuC,GACzC;EAEF,MAAM,EAAE,WAAW,MAAM,WAAW;EACpC,MAAM,YAAY,2BAA2B,IAAI,KAAK,KAAA;EAEtD,wBAAwB,QADD,YAAY,EAAE,MAAM,UAAU,IAAI,CAAC,GACV,SAAS,qBAAqB,IAAI,GAAG,aAAa;CACpG,CAAC;CAED,kBAAkB,MAAM,gBAAgB;EACtC,yBAAyB;CAC3B,CAAC;AACH;AAEA,SAAS,kBAAkB,MAAkE;CAC3F,MAAM,SAAS,QAAQ,CAAC,EAAA,CAAG;CAE3B,OAAO,aAAa,KAAK,IAAI,QAAQ,KAAA;AACvC;;;;;;AAOA,MAAa,uBAAuB,kBAAkB,qBAAqB"}
|
|
@@ -45,7 +45,7 @@ function finishClassifierEvaluation(call, message) {
|
|
|
45
45
|
});
|
|
46
46
|
if (isObjectLike(data?.input)) span.setAttribute(GEN_AI_INPUT_MESSAGES, getEvaluationInputMessages(data.input));
|
|
47
47
|
if (data?.output !== void 0) span.setAttribute(GEN_AI_OUTPUT_MESSAGES, getEvaluationOutputMessages(data.output));
|
|
48
|
-
|
|
48
|
+
call.end?.();
|
|
49
49
|
}
|
|
50
50
|
export { recordClassifierEvaluations };
|
|
51
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mastra-classifier.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/mastra-classifier.ts"],"sourcesContent":["import { GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES } from '@sentry/conventions/attributes';\nimport { isObjectLike } from '@sentry/core';\nimport type { ClassifierEvaluationCall } from '../ai/mastra/classifier-evaluation';\nimport { processClassifierEvaluationData, setStartingClassifierEvaluation } from '../ai/mastra/classifier-evaluation';\nimport { getEvaluationInputMessages, getEvaluationOutputMessages } from '../ai/core/utils';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { safeChannelCallback } from '../tracing-channel';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\n\n/**\n * Add the evaluated state, questions and answers of a `Classifier.evaluate()` call to the exporter's\n * `classifier_evaluation` span, which Mastra leaves without input or output.\n */\nexport function recordClassifierEvaluations(): void {\n const channel = diagnosticsChannel.tracingChannel<OrchestrionChannelContext>(CHANNELS.MASTRA_CLASSIFIER_EVALUATE);\n const calls = new WeakMap<object, ClassifierEvaluationCall>();\n\n channel.start.subscribe(message => {\n safeChannelCallback(() => {\n const call: ClassifierEvaluationCall = {};\n calls.set(message as object, call);\n setStartingClassifierEvaluation(call);\n });\n });\n // `evaluate()` has reached its first `await`, so Mastra has already started its span.\n channel.end.subscribe(() => {\n safeChannelCallback(() => setStartingClassifierEvaluation(undefined));\n });\n channel.asyncEnd.subscribe(message => {\n safeChannelCallback(() => {\n const call = calls.get(message as object);\n if (call) {\n finishClassifierEvaluation(call, message as OrchestrionChannelContext);\n }\n });\n });\n}\n\nfunction finishClassifierEvaluation(call: ClassifierEvaluationCall, message: OrchestrionChannelContext): void {\n call.settled = true;\n const { span, recordInputs, recordOutputs } = call;\n if (!span) {\n return;\n }\n\n const params = isObjectLike(message.arguments[0]) ? message.arguments[0] : {};\n // Questions given to the constructor take precedence over the ones passed to `evaluate()`, as in Mastra.\n const questions = (isObjectLike(message.self) ? message.self.questions : undefined) ?? params.questions;\n const data = processClassifierEvaluationData(call, {\n input: recordInputs ? { state: params.state, questions } : undefined,\n output: recordOutputs && isObjectLike(message.result) ? message.result.answers : undefined,\n });\n\n if (isObjectLike(data?.input)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES, getEvaluationInputMessages(data.input));\n }\n if (data?.output !== undefined) {\n span.setAttribute(GEN_AI_OUTPUT_MESSAGES, getEvaluationOutputMessages(data.output));\n }\n\n
|
|
1
|
+
{"version":3,"file":"mastra-classifier.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/mastra-classifier.ts"],"sourcesContent":["import { GEN_AI_INPUT_MESSAGES, GEN_AI_OUTPUT_MESSAGES } from '@sentry/conventions/attributes';\nimport { isObjectLike } from '@sentry/core';\nimport type { ClassifierEvaluationCall } from '../ai/mastra/classifier-evaluation';\nimport { processClassifierEvaluationData, setStartingClassifierEvaluation } from '../ai/mastra/classifier-evaluation';\nimport { getEvaluationInputMessages, getEvaluationOutputMessages } from '../ai/core/utils';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { safeChannelCallback } from '../tracing-channel';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\n\n/**\n * Add the evaluated state, questions and answers of a `Classifier.evaluate()` call to the exporter's\n * `classifier_evaluation` span, which Mastra leaves without input or output.\n */\nexport function recordClassifierEvaluations(): void {\n const channel = diagnosticsChannel.tracingChannel<OrchestrionChannelContext>(CHANNELS.MASTRA_CLASSIFIER_EVALUATE);\n const calls = new WeakMap<object, ClassifierEvaluationCall>();\n\n channel.start.subscribe(message => {\n safeChannelCallback(() => {\n const call: ClassifierEvaluationCall = {};\n calls.set(message as object, call);\n setStartingClassifierEvaluation(call);\n });\n });\n // `evaluate()` has reached its first `await`, so Mastra has already started its span.\n channel.end.subscribe(() => {\n safeChannelCallback(() => setStartingClassifierEvaluation(undefined));\n });\n channel.asyncEnd.subscribe(message => {\n safeChannelCallback(() => {\n const call = calls.get(message as object);\n if (call) {\n finishClassifierEvaluation(call, message as OrchestrionChannelContext);\n }\n });\n });\n}\n\nfunction finishClassifierEvaluation(call: ClassifierEvaluationCall, message: OrchestrionChannelContext): void {\n call.settled = true;\n const { span, recordInputs, recordOutputs } = call;\n if (!span) {\n return;\n }\n\n const params = isObjectLike(message.arguments[0]) ? message.arguments[0] : {};\n // Questions given to the constructor take precedence over the ones passed to `evaluate()`, as in Mastra.\n const questions = (isObjectLike(message.self) ? message.self.questions : undefined) ?? params.questions;\n const data = processClassifierEvaluationData(call, {\n input: recordInputs ? { state: params.state, questions } : undefined,\n output: recordOutputs && isObjectLike(message.result) ? message.result.answers : undefined,\n });\n\n if (isObjectLike(data?.input)) {\n span.setAttribute(GEN_AI_INPUT_MESSAGES, getEvaluationInputMessages(data.input));\n }\n if (data?.output !== undefined) {\n span.setAttribute(GEN_AI_OUTPUT_MESSAGES, getEvaluationOutputMessages(data.output));\n }\n\n call.end?.();\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,8BAAoC;CAClD,MAAM,UAAUA,eAA6D,SAAS,0BAA0B;CAChH,MAAM,wBAAQ,IAAI,QAA0C;CAE5D,QAAQ,MAAM,WAAU,YAAW;EACjC,0BAA0B;GACxB,MAAM,OAAiC,CAAC;GACxC,MAAM,IAAI,SAAmB,IAAI;GACjC,gCAAgC,IAAI;EACtC,CAAC;CACH,CAAC;CAED,QAAQ,IAAI,gBAAgB;EAC1B,0BAA0B,gCAAgC,KAAA,CAAS,CAAC;CACtE,CAAC;CACD,QAAQ,SAAS,WAAU,YAAW;EACpC,0BAA0B;GACxB,MAAM,OAAO,MAAM,IAAI,OAAiB;GACxC,IAAI,MACF,2BAA2B,MAAM,OAAoC;EAEzE,CAAC;CACH,CAAC;AACH;AAEA,SAAS,2BAA2B,MAAgC,SAA0C;CAC5G,KAAK,UAAU;CACf,MAAM,EAAE,MAAM,cAAc,kBAAkB;CAC9C,IAAI,CAAC,MACH;CAGF,MAAM,SAAS,aAAa,QAAQ,UAAU,EAAE,IAAI,QAAQ,UAAU,KAAK,CAAC;CAE5E,MAAM,aAAa,aAAa,QAAQ,IAAI,IAAI,QAAQ,KAAK,YAAY,KAAA,MAAc,OAAO;CAC9F,MAAM,OAAO,gCAAgC,MAAM;EACjD,OAAO,eAAe;GAAE,OAAO,OAAO;GAAO;EAAU,IAAI,KAAA;EAC3D,QAAQ,iBAAiB,aAAa,QAAQ,MAAM,IAAI,QAAQ,OAAO,UAAU,KAAA;CACnF,CAAC;CAED,IAAI,aAAa,MAAM,KAAK,GAC1B,KAAK,aAAa,uBAAuB,2BAA2B,KAAK,KAAK,CAAC;CAEjF,IAAI,MAAM,WAAW,KAAA,GACnB,KAAK,aAAa,wBAAwB,4BAA4B,KAAK,MAAM,CAAC;CAGpF,KAAK,MAAM;AACb"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { tracingChannel } from "../utils/diagnosticsChannel.js";
|
|
2
|
-
import { getGenAiSpanOp,
|
|
2
|
+
import { getGenAiSpanOp, markCancelledIfAborted, resolveGenAiCallRecording } from "../ai/core/utils.js";
|
|
3
|
+
import { runGenAiSpanEnd, runGenAiSpanStart } from "../ai/core/span-hooks.js";
|
|
3
4
|
import { addRequestAttributes, extractRequestAttributes } from "../ai/mistral/index.js";
|
|
4
5
|
import { MISTRAL_INTEGRATION_NAME, MISTRAL_ORIGIN } from "../ai/mistral/constants.js";
|
|
5
6
|
import { instrumentEventStream } from "../ai/mistral/streaming.js";
|
|
6
|
-
import { addResponseAttributes, getSpanName } from "../ai/mistral/utils.js";
|
|
7
|
+
import { addResponseAttributes, getMistralRequestSignal, getSpanName } from "../ai/mistral/utils.js";
|
|
7
8
|
import { shouldSkipAiProviderSpan } from "../ai/pi-ai/providers.js";
|
|
8
9
|
import { CHANNELS } from "../orchestrion/channels.js";
|
|
9
10
|
import { mistralModuleNames } from "../orchestrion/config/mistral.js";
|
|
@@ -51,9 +52,11 @@ const _mistralAIIntegration = ((options = {}) => {
|
|
|
51
52
|
function instrumentMistral(options) {
|
|
52
53
|
for (const { channel, operation, streaming } of INSTRUMENTED_CHANNELS) bindTracingChannelToSpan(tracingChannel(channel), (data) => createGenAiSpan(data, operation, streaming, options), {
|
|
53
54
|
beforeSpanEnd: (span, data) => {
|
|
54
|
-
|
|
55
|
+
if ("error" in data) markCancelledIfAborted(span, getMistralRequestSignal(data.arguments?.[1]));
|
|
56
|
+
addResponseAttributes(span, data.result, !!data._sentryRecordOutputs);
|
|
57
|
+
data._sentryOnSpanEnd?.("error" in data ? { error: data.error } : { response: data.result });
|
|
55
58
|
},
|
|
56
|
-
deferSpanEnd: ({ span, data }) => streaming && instrumentEventStream(data.result, span,
|
|
59
|
+
deferSpanEnd: ({ span, data }) => streaming && instrumentEventStream(data.result, span, !!data._sentryRecordOutputs, getMistralRequestSignal(data.arguments?.[1]), data._sentryOnSpanEnd)
|
|
57
60
|
});
|
|
58
61
|
}
|
|
59
62
|
/**
|
|
@@ -64,7 +67,12 @@ function createGenAiSpan(data, operation, streaming, options) {
|
|
|
64
67
|
if (shouldSkipAiProviderSpan(INTEGRATION_NAME)) return;
|
|
65
68
|
const args = data.arguments ?? [];
|
|
66
69
|
const params = args[0];
|
|
67
|
-
const
|
|
70
|
+
const call = {
|
|
71
|
+
operation,
|
|
72
|
+
request: params
|
|
73
|
+
};
|
|
74
|
+
const { recordInputs, recordOutputs } = resolveGenAiCallRecording(options, call);
|
|
75
|
+
data._sentryRecordOutputs = recordOutputs;
|
|
68
76
|
const attributes = extractRequestAttributes(args, operation, recordInputs, streaming);
|
|
69
77
|
attributes[SENTRY_ORIGIN] = MISTRAL_ORIGIN;
|
|
70
78
|
const span = startInactiveSpan({
|
|
@@ -73,6 +81,8 @@ function createGenAiSpan(data, operation, streaming, options) {
|
|
|
73
81
|
attributes
|
|
74
82
|
});
|
|
75
83
|
if (recordInputs && params) addRequestAttributes(span, params, operation);
|
|
84
|
+
runGenAiSpanStart(options, span, call);
|
|
85
|
+
data._sentryOnSpanEnd = (result) => runGenAiSpanEnd(options, span, call, result);
|
|
76
86
|
return span;
|
|
77
87
|
}
|
|
78
88
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mistral.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/mistral.ts"],"sourcesContent":["import { SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';\nimport { defineIntegration, startInactiveSpan } from '@sentry/core';\nimport { getGenAiSpanOp,
|
|
1
|
+
{"version":3,"file":"mistral.js","names":["diagnosticsChannel.tracingChannel"],"sources":["../../../src/integrations/mistral.ts"],"sourcesContent":["import { SENTRY_ORIGIN } from '@sentry/conventions/attributes';\nimport * as diagnosticsChannel from '../utils/diagnosticsChannel';\nimport type { IntegrationFn, Span, SpanAttributeValue } from '@sentry/core';\nimport { defineIntegration, startInactiveSpan } from '@sentry/core';\nimport { getGenAiSpanOp, markCancelledIfAborted, resolveGenAiCallRecording } from '../ai/core/utils';\nimport { type GenAiSpanResult, runGenAiSpanEnd, runGenAiSpanStart } from '../ai/core/span-hooks';\nimport { addRequestAttributes, extractRequestAttributes } from '../ai/mistral';\nimport { MISTRAL_INTEGRATION_NAME, MISTRAL_ORIGIN } from '../ai/mistral/constants';\nimport { instrumentEventStream } from '../ai/mistral/streaming';\nimport type { MistralCallInfo, MistralOptions } from '../ai/mistral/types';\nimport { addResponseAttributes, getMistralRequestSignal, getSpanName } from '../ai/mistral/utils';\nimport { shouldSkipAiProviderSpan } from '../ai/pi-ai/providers';\nimport type { OrchestrionChannelContext } from '../orchestrion/types';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { mistralModuleNames } from '../orchestrion/config/mistral';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\nimport { bindTracingChannelToSpan } from '../tracing-channel';\n\nconst INTEGRATION_NAME = MISTRAL_INTEGRATION_NAME;\n\n// The recording decision is made once, when the span starts, in the caller's async context.\ntype MistralChannelContext = OrchestrionChannelContext & {\n _sentryRecordOutputs?: boolean;\n _sentryOnSpanEnd?: (result: GenAiSpanResult<unknown>) => void;\n};\n\n// Each instrumented channel maps to the gen_ai operation its span reports. Streaming methods publish\n// on their own channel, so the span knows it is a stream before the result exists.\nconst INSTRUMENTED_CHANNELS = [\n { channel: CHANNELS.MISTRAL_CHAT, operation: 'chat', streaming: false },\n { channel: CHANNELS.MISTRAL_CHAT_STREAM, operation: 'chat', streaming: true },\n { channel: CHANNELS.MISTRAL_EMBEDDINGS, operation: 'embeddings', streaming: false },\n { channel: CHANNELS.MISTRAL_AGENTS, operation: 'invoke_agent', streaming: false },\n { channel: CHANNELS.MISTRAL_AGENTS_STREAM, operation: 'invoke_agent', streaming: true },\n] as const;\n\nconst _mistralAIIntegration = ((options: MistralOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, mistralModuleNames, instrumentMistral, [options]);\n },\n };\n}) satisfies IntegrationFn;\n\nfunction instrumentMistral(options: MistralOptions): void {\n for (const { channel, operation, streaming } of INSTRUMENTED_CHANNELS) {\n bindTracingChannelToSpan(\n diagnosticsChannel.tracingChannel<MistralChannelContext>(channel),\n data => createGenAiSpan(data, operation, streaming, options),\n {\n beforeSpanEnd: (span, data) => {\n if ('error' in data) {\n markCancelledIfAborted(span, getMistralRequestSignal(data.arguments?.[1]));\n }\n addResponseAttributes(span, data.result, !!data._sentryRecordOutputs);\n data._sentryOnSpanEnd?.('error' in data ? { error: data.error } : { response: data.result });\n },\n // Streaming: the result is an `EventStream` consumed later, so instrument it and let it end the span.\n deferSpanEnd: ({ span, data }) =>\n streaming &&\n instrumentEventStream(\n data.result,\n span,\n !!data._sentryRecordOutputs,\n getMistralRequestSignal(data.arguments?.[1]),\n data._sentryOnSpanEnd,\n ),\n },\n );\n }\n}\n\n/**\n * Build the span for an instrumented Mistral call.\n * Returning `undefined` opts the payload out so no span is opened.\n */\nfunction createGenAiSpan(\n data: MistralChannelContext,\n operation: string,\n streaming: boolean,\n options: MistralOptions,\n): Span | undefined {\n if (shouldSkipAiProviderSpan(INTEGRATION_NAME)) {\n return undefined;\n }\n\n const args = data.arguments ?? [];\n const params = args[0] as Record<string, unknown> | undefined;\n\n const call: MistralCallInfo = { operation, request: params };\n const { recordInputs, recordOutputs } = resolveGenAiCallRecording(options, call);\n data._sentryRecordOutputs = recordOutputs;\n\n const attributes = extractRequestAttributes(args, operation, recordInputs, streaming);\n attributes[SENTRY_ORIGIN] = MISTRAL_ORIGIN;\n\n const span = startInactiveSpan({\n name: getSpanName(operation, attributes),\n op: getGenAiSpanOp(operation),\n attributes: attributes as Record<string, SpanAttributeValue>,\n });\n\n if (recordInputs && params) {\n addRequestAttributes(span, params, operation);\n }\n\n runGenAiSpanStart(options, span, call);\n data._sentryOnSpanEnd = result => runGenAiSpanEnd(options, span, call, result);\n\n return span;\n}\n\n/**\n * An integration to instrument @mistralai/mistrailai.\n */\nexport const mistralAIIntegration = defineIntegration(_mistralAIIntegration);\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,mBAAmB;AAUzB,MAAM,wBAAwB;CAC5B;EAAE,SAAS,SAAS;EAAc,WAAW;EAAQ,WAAW;CAAM;CACtE;EAAE,SAAS,SAAS;EAAqB,WAAW;EAAQ,WAAW;CAAK;CAC5E;EAAE,SAAS,SAAS;EAAoB,WAAW;EAAc,WAAW;CAAM;CAClF;EAAE,SAAS,SAAS;EAAgB,WAAW;EAAgB,WAAW;CAAM;CAChF;EAAE,SAAS,SAAS;EAAuB,WAAW;EAAgB,WAAW;CAAK;AACxF;AAEA,MAAM,0BAA0B,UAA0B,CAAC,MAAM;CAC/D,OAAO;EACL,MAAM;EACN,MAAM,QAAQ;GACZ,iCAAiC,QAAQ,oBAAoB,mBAAmB,CAAC,OAAO,CAAC;EAC3F;CACF;AACF;AAEA,SAAS,kBAAkB,SAA+B;CACxD,KAAK,MAAM,EAAE,SAAS,WAAW,eAAe,uBAC9C,yBACEA,eAAyD,OAAO,IAChE,SAAQ,gBAAgB,MAAM,WAAW,WAAW,OAAO,GAC3D;EACE,gBAAgB,MAAM,SAAS;GAC7B,IAAI,WAAW,MACb,uBAAuB,MAAM,wBAAwB,KAAK,YAAY,EAAE,CAAC;GAE3E,sBAAsB,MAAM,KAAK,QAAQ,CAAC,CAAC,KAAK,oBAAoB;GACpE,KAAK,mBAAmB,WAAW,OAAO,EAAE,OAAO,KAAK,MAAM,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;EAC7F;EAEA,eAAe,EAAE,MAAM,WACrB,aACA,sBACE,KAAK,QACL,MACA,CAAC,CAAC,KAAK,sBACP,wBAAwB,KAAK,YAAY,EAAE,GAC3C,KAAK,gBACP;CACJ,CACF;AAEJ;;;;;AAMA,SAAS,gBACP,MACA,WACA,WACA,SACkB;CAClB,IAAI,yBAAyB,gBAAgB,GAC3C;CAGF,MAAM,OAAO,KAAK,aAAa,CAAC;CAChC,MAAM,SAAS,KAAK;CAEpB,MAAM,OAAwB;EAAE;EAAW,SAAS;CAAO;CAC3D,MAAM,EAAE,cAAc,kBAAkB,0BAA0B,SAAS,IAAI;CAC/E,KAAK,uBAAuB;CAE5B,MAAM,aAAa,yBAAyB,MAAM,WAAW,cAAc,SAAS;CACpF,WAAW,iBAAiB;CAE5B,MAAM,OAAO,kBAAkB;EAC7B,MAAM,YAAY,WAAW,UAAU;EACvC,IAAI,eAAe,SAAS;EAChB;CACd,CAAC;CAED,IAAI,gBAAgB,QAClB,qBAAqB,MAAM,QAAQ,SAAS;CAG9C,kBAAkB,SAAS,MAAM,IAAI;CACrC,KAAK,oBAAmB,WAAU,gBAAgB,SAAS,MAAM,MAAM,MAAM;CAE7E,OAAO;AACT;;;;AAKA,MAAa,uBAAuB,kBAAkB,qBAAqB"}
|
|
@@ -33,7 +33,7 @@ function wrapTask(args, options, isReadAlike) {
|
|
|
33
33
|
}
|
|
34
34
|
/** The monitor config for a task, or `undefined` if `isReadAlike` says this node-cron version reads it differently. */
|
|
35
35
|
function getMonitorConfig(expression, timezone, isReadAlike) {
|
|
36
|
-
return isReadAlike && !isReadAlike(expression) ? void 0 : cronExpressionToMonitorConfig(expression, timezone, "
|
|
36
|
+
return isReadAlike && !isReadAlike(expression) ? void 0 : cronExpressionToMonitorConfig(expression, timezone, "node-cron");
|
|
37
37
|
}
|
|
38
38
|
const NODE_CRON_3_FIELD_MINIMUMS = [
|
|
39
39
|
0,
|
|
@@ -44,11 +44,12 @@ const NODE_CRON_3_FIELD_MINIMUMS = [
|
|
|
44
44
|
];
|
|
45
45
|
/**
|
|
46
46
|
* 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.
|
|
47
|
-
* Returns `false`
|
|
47
|
+
* It also reads a step without a range, like `5/10`, as its start. Returns `false` where that could differ.
|
|
48
48
|
*/
|
|
49
49
|
function isReadAlikeByNodeCron4(expression) {
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
const fields = expression.trim().split(/\s+/);
|
|
51
|
+
const weekday = fields[fields.length - 1] || "";
|
|
52
|
+
return !(weekday.includes("-") && (weekday.includes("7") || /-(?:0|sun)/i.test(weekday))) && !fields.some((field) => field.split(",").some((part) => /^[a-z\d]+\//i.test(part)));
|
|
52
53
|
}
|
|
53
54
|
/**
|
|
54
55
|
* node-cron 3 keeps the values of a stepped field that are multiples of the step (`*\/2` days are 2, 4, ...)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-cron.js","names":[],"sources":["../../../src/integrations/node-cron.ts"],"sourcesContent":["import type { IntegrationFn, MonitorConfig } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { nodeCronModuleNames } from '../orchestrion/config/node-cron';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\nimport type { AnyFn } from '../utils/cronMonitoring';\nimport {\n cronExpressionToMonitorConfig,\n shouldMonitorJob,\n subscribeToJobCreation,\n wrapScheduledJob,\n} from '../utils/cronMonitoring';\n\nconst INTEGRATION_NAME = 'NodeCron' as const;\n\nexport interface NodeCronIntegrationOptions {\n /** Task names not to monitor. Strings must match the name exactly. */\n excludeJobs?: Array<string | RegExp>;\n}\n\nconst _nodeCronIntegration = ((options: NodeCronIntegrationOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, nodeCronModuleNames, subscribe, [options], {\n // The binding only parents spans, and this integration creates none.\n requiresTracingChannelBinding: false,\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Sends Crons check-ins for every named `node-cron` task, with its schedule as the monitor config.\n * The monitor slug is the task's `name` option. Tasks without a name, or with a schedule Sentry can't express, are not\n * monitored.\n */\nexport const nodeCronIntegration = defineIntegration(_nodeCronIntegration);\n\nfunction subscribe(options: NodeCronIntegrationOptions): void {\n subscribeToJobCreation(CHANNELS.NODE_CRON_CREATE_TASK, INTEGRATION_NAME, args => wrapTask(args, options));\n subscribeToJobCreation(CHANNELS.NODE_CRON_V4_CREATE_TASK, INTEGRATION_NAME, args =>\n wrapTask(args, options, isReadAlikeByNodeCron4),\n );\n subscribeToJobCreation(CHANNELS.NODE_CRON_V3_CREATE_TASK, INTEGRATION_NAME, args =>\n wrapTask(args, options, isReadAlikeByNodeCron3),\n );\n}\n\n// `createTask(expression, func, options)`\nfunction wrapTask(\n args: unknown[],\n options: NodeCronIntegrationOptions,\n isReadAlike?: (expression: string) => boolean,\n): void {\n const [expression, func, taskOptions] = args;\n const { name, timezone } = (taskOptions || {}) as { name?: unknown; timezone?: unknown };\n if (!shouldMonitorJob(name, func, options.excludeJobs)) {\n return;\n }\n const monitorConfig = getMonitorConfig(String(expression), timezone, isReadAlike);\n args[1] = wrapScheduledJob(func as AnyFn, name, monitorConfig, 'auto.function.node-cron');\n}\n\n/** The monitor config for a task, or `undefined` if `isReadAlike` says this node-cron version reads it differently. */\nexport function getMonitorConfig(\n expression: string,\n timezone: unknown,\n isReadAlike?: (expression: string) => boolean,\n): MonitorConfig | undefined {\n return isReadAlike && !isReadAlike(expression)\n ? undefined\n : cronExpressionToMonitorConfig(expression, timezone, '
|
|
1
|
+
{"version":3,"file":"node-cron.js","names":[],"sources":["../../../src/integrations/node-cron.ts"],"sourcesContent":["import type { IntegrationFn, MonitorConfig } from '@sentry/core';\nimport { defineIntegration } from '@sentry/core';\nimport { CHANNELS } from '../orchestrion/channels';\nimport { nodeCronModuleNames } from '../orchestrion/config/node-cron';\nimport { invokeOrchestrionInstrumentation } from '../orchestrion/instrumentation';\nimport type { AnyFn } from '../utils/cronMonitoring';\nimport {\n cronExpressionToMonitorConfig,\n shouldMonitorJob,\n subscribeToJobCreation,\n wrapScheduledJob,\n} from '../utils/cronMonitoring';\n\nconst INTEGRATION_NAME = 'NodeCron' as const;\n\nexport interface NodeCronIntegrationOptions {\n /** Task names not to monitor. Strings must match the name exactly. */\n excludeJobs?: Array<string | RegExp>;\n}\n\nconst _nodeCronIntegration = ((options: NodeCronIntegrationOptions = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n invokeOrchestrionInstrumentation(client, nodeCronModuleNames, subscribe, [options], {\n // The binding only parents spans, and this integration creates none.\n requiresTracingChannelBinding: false,\n });\n },\n };\n}) satisfies IntegrationFn;\n\n/**\n * Sends Crons check-ins for every named `node-cron` task, with its schedule as the monitor config.\n * The monitor slug is the task's `name` option. Tasks without a name, or with a schedule Sentry can't express, are not\n * monitored.\n */\nexport const nodeCronIntegration = defineIntegration(_nodeCronIntegration);\n\nfunction subscribe(options: NodeCronIntegrationOptions): void {\n subscribeToJobCreation(CHANNELS.NODE_CRON_CREATE_TASK, INTEGRATION_NAME, args => wrapTask(args, options));\n subscribeToJobCreation(CHANNELS.NODE_CRON_V4_CREATE_TASK, INTEGRATION_NAME, args =>\n wrapTask(args, options, isReadAlikeByNodeCron4),\n );\n subscribeToJobCreation(CHANNELS.NODE_CRON_V3_CREATE_TASK, INTEGRATION_NAME, args =>\n wrapTask(args, options, isReadAlikeByNodeCron3),\n );\n}\n\n// `createTask(expression, func, options)`\nfunction wrapTask(\n args: unknown[],\n options: NodeCronIntegrationOptions,\n isReadAlike?: (expression: string) => boolean,\n): void {\n const [expression, func, taskOptions] = args;\n const { name, timezone } = (taskOptions || {}) as { name?: unknown; timezone?: unknown };\n if (!shouldMonitorJob(name, func, options.excludeJobs)) {\n return;\n }\n const monitorConfig = getMonitorConfig(String(expression), timezone, isReadAlike);\n args[1] = wrapScheduledJob(func as AnyFn, name, monitorConfig, 'auto.function.node-cron');\n}\n\n/** The monitor config for a task, or `undefined` if `isReadAlike` says this node-cron version reads it differently. */\nexport function getMonitorConfig(\n expression: string,\n timezone: unknown,\n isReadAlike?: (expression: string) => boolean,\n): MonitorConfig | undefined {\n return isReadAlike && !isReadAlike(expression)\n ? undefined\n : cronExpressionToMonitorConfig(expression, timezone, 'node-cron');\n}\n\nconst NODE_CRON_3_FIELD_MINIMUMS = [0, 0, 1, 1, 0];\n\n/**\n * 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.\n * It also reads a step without a range, like `5/10`, as its start. Returns `false` where that could differ.\n */\nexport function isReadAlikeByNodeCron4(expression: string): boolean {\n const fields = expression.trim().split(/\\s+/);\n const weekday = fields[fields.length - 1] || '';\n return (\n !(weekday.includes('-') && (weekday.includes('7') || /-(?:0|sun)/i.test(weekday))) &&\n !fields.some(field => field.split(',').some(part => /^[a-z\\d]+\\//i.test(part)))\n );\n}\n\n/**\n * node-cron 3 keeps the values of a stepped field that are multiples of the step (`*\\/2` days are 2, 4, ...)\n * and reads weekday ranges like node-cron 4 before 4.6. Returns `false` where that differs from standard cron.\n */\nexport function isReadAlikeByNodeCron3(expression: string): boolean {\n const fields = expression.trim().split(/\\s+/);\n const minimums = fields.length === 6 ? [0, ...NODE_CRON_3_FIELD_MINIMUMS] : NODE_CRON_3_FIELD_MINIMUMS;\n return (\n isReadAlikeByNodeCron4(expression) &&\n fields.every((field, index) => {\n if (!field.includes('/')) {\n return true;\n }\n const match = /^(?:\\*|(\\d+)-\\d+)\\/(\\d+)$/.exec(field);\n return !!match && Number(match[1] ?? minimums[index]) % Number(match[2]) === 0;\n })\n );\n}\n"],"mappings":";;;;;;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AAC,CAAC,MAAK,SAAQ,eAAe,KAAK,IAAI,CAAC,CAAC;AAElF;;;;;AAMA,SAAgB,uBAAuB,YAA6B;CAClE,MAAM,SAAS,WAAW,KAAK,CAAC,CAAC,MAAM,KAAK;CAC5C,MAAM,WAAW,OAAO,WAAW,IAAI,CAAC,GAAG,GAAG,0BAA0B,IAAI;CAC5E,OACE,uBAAuB,UAAU,KACjC,OAAO,OAAO,OAAO,UAAU;EAC7B,IAAI,CAAC,MAAM,SAAS,GAAG,GACrB,OAAO;EAET,MAAM,QAAQ,4BAA4B,KAAK,KAAK;EACpD,OAAO,CAAC,CAAC,SAAS,OAAO,MAAM,MAAM,SAAS,MAAM,IAAI,OAAO,MAAM,EAAE,MAAM;CAC/E,CAAC;AAEL"}
|
|
@@ -55,9 +55,9 @@ function isCronShaped(value) {
|
|
|
55
55
|
return /^@[a-z]+$/i.test(value.trim()) || (fields.length === 5 || fields.length === 6) && fields.every((field) => /^[\d*,/?#a-z-]+$/i.test(field));
|
|
56
56
|
}
|
|
57
57
|
function getMonitorConfig(spec) {
|
|
58
|
-
if (typeof spec === "string") return cronExpressionToMonitorConfig(spec, void 0, "
|
|
58
|
+
if (typeof spec === "string") return cronExpressionToMonitorConfig(spec, void 0, "cron-parser");
|
|
59
59
|
const { rule, tz, start, end } = spec || {};
|
|
60
|
-
return typeof rule === "string" && !start && !end ? cronExpressionToMonitorConfig(rule, tz, "
|
|
60
|
+
return typeof rule === "string" && !start && !end ? cronExpressionToMonitorConfig(rule, tz, "cron-parser") : void 0;
|
|
61
61
|
}
|
|
62
62
|
export { beforeSchedule, getMonitorConfig, isOneOffSpec, nodeScheduleIntegration, onSchedule };
|
|
63
63
|
|