Skip to content

feat(node): Add first-party Mastra integration - #23823

Draft
RulaKhaled wants to merge 1 commit into
developfrom
rolaabuhasna/mastra-exporter
Draft

feat(node): Add first-party Mastra integration#23823
RulaKhaled wants to merge 1 commit into
developfrom
rolaabuhasna/mastra-exporter

Conversation

@RulaKhaled

@RulaKhaled RulaKhaled commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Mastra agent traces now come from the SDK: invoke_agent, chat, and execute_tool spans, on by default for Node-family SDKs.

Ref JS-3455 (dup JSSDK-21).

How it attaches

  • Hooks the Mastra constructor and registers our exporter via registerExporter().
  • If the app already has observability, we attach to it.
  • If it doesn’t, we bootstrap a pipeline from @mastra/observability when that package is already installed. We never add it ourselves.
  • You can also register the exporter by hand.

What we emit

  • Only ops, names, and attributes from sentry-conventions.
  • Span types with no conventional op (workflow_step, memory_operation, processor_run, scorer_*) are dropped; children re-parent onto the nearest exported ancestor.
  • model_inference is dropped too. Mastra nests model_generation > model_step > model_inference, and the inference span repeats the generation’s model/usage — exporting both produced a duplicate nested chat per step. model_generation is the gen_ai.chat span.

Note to reviewer: 🗯️

This diff is large mostly because of Node integration tests and the @mastra/* yarn.lock bump, not because the SDK surface is huge.

The product decisions are in three files:

  • packages/server-utils/src/ai/mastra/utils.ts — span names and gen_ai.* attributes
  • packages/server-utils/src/ai/mastra/index.ts — exporter (drop unmapped types, re-parent children)
  • packages/server-utils/src/integrations/mastra.ts — constructor attach, bootstrap, skip duplicate provider wrapping

If you are checking that auto-instrumentation actually hooks Mastra, also glance at packages/server-utils/src/orchestrion/config/mastra.ts

@linear-code

linear-code Bot commented Sep 1, 2026

Copy link
Copy Markdown

JS-3455

@RulaKhaled
RulaKhaled force-pushed the rolaabuhasna/mastra-exporter branch from b5821be to 2c85c6e Compare September 1, 2026 10:11
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.57 kB - -
@sentry/browser - with treeshaking flags 26.94 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.83 kB - -
@sentry/browser (incl. Tracing) 48.87 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.88 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.8 kB - -
@sentry/browser (incl. Tracing, Replay) 88.36 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.76 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 93.05 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 106.02 kB - -
@sentry/browser (incl. Feedback) 46.06 kB - -
@sentry/browser (incl. sendFeedback) 33.64 kB - -
@sentry/browser (incl. FeedbackAsync) 38.74 kB - -
@sentry/browser (incl. Metrics) 29.52 kB - -
@sentry/browser (incl. Logs) 29.81 kB - -
@sentry/browser (incl. Metrics & Logs) 30.45 kB - -
@sentry/react 30.32 kB - -
@sentry/react (incl. Tracing) 51.08 kB - -
@sentry/vue 35.74 kB - -
@sentry/vue (incl. Tracing) 51.14 kB - -
@sentry/svelte 28.6 kB - -
CDN Bundle 30.36 kB - -
CDN Bundle (incl. Tracing) 49.52 kB - -
CDN Bundle (incl. Logs, Metrics) 32.59 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 51.43 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.19 kB - -
CDN Bundle (incl. Tracing, Replay) 87.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.84 kB - -
CDN Bundle - uncompressed 89.97 kB - -
CDN Bundle (incl. Tracing) - uncompressed 147.58 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.27 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.27 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.43 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.75 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.44 kB - -
@sentry/nextjs (client) 53.7 kB - -
@sentry/sveltekit (client) 49.3 kB - -
@sentry/core/server 40.72 kB - -
@sentry/core/browser 13.42 kB - -
@sentry/node 126.24 kB +1.95% +2.41 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.46 kB +0.08% +64 B 🔺
@sentry/node - without tracing 88.2 kB +0.1% +86 B 🔺
@sentry/node - without channel injection 105.69 kB +2.36% +2.43 kB 🔺
@sentry/aws-serverless 96.56 kB +0.1% +96 B 🔺
@sentry/cloudflare (withSentry) - minified 201.23 kB - -
@sentry/cloudflare (withSentry) 500.94 kB - -

View base workflow run

Mastra is exporter-based, so we hook the constructor, register a Sentry exporter, and bootstrap an observability pipeline when the app has not configured one.
@RulaKhaled
RulaKhaled force-pushed the rolaabuhasna/mastra-exporter branch from 8beaa13 to 18578a1 Compare September 1, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant