feat(mastra): support Mastra v1 observability + map spans to gen_ai conventions#182
Merged
Conversation
…onventions Mastra v1 (>=1.16) removed the `telemetry:` config key that the old FITraceExporter plugged into, so traces silently stopped exporting. This adds a v1-native path: - createFIObservability() / createFIMastraExporter(): wire Future AGI into Mastra's v1 `observability` API with the correct collector host (api.futureagi.com), x-api-key/x-secret-key auth, and project_name/project_type resource attributes (without project_name the trace is accepted but no project is created). - FIMastraSpanExporter: reuses @mastra/otel-exporter's SpanConverter, then enriches each span with gen_ai.span.kind (mapped from the Mastra span type) and input.value/output.value, so spans render with the right kind (not "unknown") and their I/O in Future AGI. - Excludes MODEL_CHUNK streaming spans by default. - Legacy v0.x FITraceExporter/isFISpan moved to the `@traceai/mastra/legacy` subpath so v1 users don't pull @traceai/vercel. - Adds unit tests for the enrichment and factory/resolver logic.
JayaSurya-27
requested changes
Jun 3, 2026
JayaSurya-27
approved these changes
Jun 3, 2026
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.
Summary
@traceai/mastrawas broken on Mastra v1 (@mastra/core>= 1.16): v1 removed thetelemetry:config key the oldFITraceExporterplugged into, so traces silently stopped exporting. This PR adds a v1-native integration.What's included
createFIObservability()/createFIMastraExporter()— wire Future AGI into Mastra's v1observabilityAPI. Bakes in the things that are easy to get wrong:api.futureagi.com(notapp.futureagi.com, which is GET-only and 403s)x-api-key/x-secret-keyauth fromFI_API_KEY/FI_SECRET_KEYproject_name/project_typeresource attributes (withoutproject_name, the trace is accepted but no project is created)FIMastraSpanExporter— a customObservabilityExporterthat reuses@mastra/otel-exporter'sSpanConverter(Mastra span → OTLPgen_ai.*), then enriches each span with:gen_ai.span.kindmapped from the Mastra span type (AGENT / LLM / TOOL / CHAIN) so spans aren't typed "unknown"input.value/output.value(+ mime) so prompt/response/tool I/O renders in the trace UIMODEL_CHUNKstreaming spans by default.FITraceExporter/isFISpanmoved to the@traceai/mastra/legacysubpath so v1 users don't pull@traceai/vercel.Screenshot
Testing
pnpm --filter @traceai/mastra run build— cleanpnpm --filter @traceai/mastra run test— 33/33 passingapi.futureagi.com: project created, trace + spans render with correct kinds (AGENT/LLM/TOOL/CHAIN) and input/output.Docs
Companion PR updates the Mastra integration docs in the docs repo.