feat(node): Add first-party Mastra integration - #23823
Draft
RulaKhaled wants to merge 1 commit into
Draft
Conversation
RulaKhaled
force-pushed
the
rolaabuhasna/mastra-exporter
branch
from
September 1, 2026 10:11
b5821be to
2c85c6e
Compare
Contributor
size-limit report 📦
|
RulaKhaled
force-pushed
the
rolaabuhasna/mastra-exporter
branch
from
September 1, 2026 15:38
8beaa13 to
18578a1
Compare
isaacs
added a commit
that referenced
this pull request
Sep 1, 2026
Name `handler` spans after the route they serve when span streaming is enabled, or `Request handler` if no route set. Static mode left as is. Drop Hapi method, as the template dictates. NestJS resolves no route when the span starts. The NestJS callback name stays on `nestjs.callback`. Elysia sets `context.route` when the request enters the compiled handler, which is before the `Handle` phase reports. Read it in the trace listener so streamed handler spans carry the route instead of the `Request handler` fallback. The fallback now applies only when the context has no route. Set `code.function.name` only when the handler has a name. Static mode keeps the handler name in the span name, so the attribute adds nothing there, and an anonymous handler has no name to record. Adding convention for `code.function.name` in general is tracked in #23823. Register the Fastify test route from a plugin. Fastify installs the SDK's `onRoute` hook when it flushes its plugin list, which is after root-level routes are in place. A root-level route therefore produces no route handler span, and the test never reached that code path. Also: correct `REQUEST_HANDLER_SPAN_NAME_FALLBACK`: the conventions spell the fallback `Request handler`, and its `@see` link pointed at the resource section. closes #23533 --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
force-pushed
the
rolaabuhasna/mastra-exporter
branch
from
September 1, 2026 21:27
9f48b17 to
a45a5db
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mastra agent traces now come from the SDK:
invoke_agent,chat, andexecute_toolspans, on by default for Node-family SDKs.Ref JS-3455 (dup JSSDK-21).
How it attaches
Mastraconstructor and registers our exporter viaregisterExporter().@mastra/observabilitywhen that package is already installed. We never add it ourselves.What we emit
workflow_step,memory_operation,processor_run,scorer_*) are dropped; children re-parent onto the nearest exported ancestor.model_inferenceis dropped too. Mastra nestsmodel_generation > model_step > model_inference, and the inference span repeats the generation’s model/usage — exporting both produced a duplicate nestedchatper step.model_generationis thegen_ai.chatspan.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:
If you are checking that auto-instrumentation actually hooks Mastra, also glance at packages/server-utils/src/orchestrion/config/mastra.ts