Choose a setup method
Start with one method for a call path. Combining SDK tracking with framework
OpenTelemetry on the same call can create duplicate interactions.
Recommended: Agnost AI skill
Recommended. Choose this path when you want your coding agent to inspect the
project, select a supported transport, make the smallest instrumentation change,
send a test event, and verify that it reached Agnost AI.
Manual setup: Agnost AI SDK
Manual setup: OpenTelemetry
Mastra ships anOtelExporter that targets any OTLP endpoint. Wire it into your Mastra instance, then pass userId / conversationId per call.
1. Install
Already have@mastra/observability and @mastra/otel-exporter? Skip.
No Observability set up yet?
2. Wire the OtelExporter pointing at Agnost AI
Already have Mastra Observability? Append Agnost AI to the existingexporters array: Mastra fans traces out to every exporter in the list:
3. Pass userId / conversationId per call
userId, conversationId, and threadId in tracingOptions.metadata are read by Agnost AI for user / session grouping.
What appears in Agnost AI
- Conversations grouped by
conversationIdorthreadId. - User-level analytics grouped by
userId. - Events for spans exported by Mastra.
Verify
Run oneagent.generate call, then open Events in Agnost AI. Confirm the span has your userId and conversationId.
Troubleshooting
- Confirm the
OtelExporteris included in the active Mastra observability config. - Confirm
protocol: 'http/protobuf'and/v1/tracesare used. - Confirm metadata keys are spelled
userId,conversationId, orthreadId.
References
Next steps
- Conversations: review the complete Mastra interaction.
- Events: inspect agent and model activity.
- Intents: organize production conversations by what users wanted.
