Skip to main content
Mastra ships an OtelExporter that targets any OTLP endpoint. Wire it into your Mastra instance, then pass userId / conversationId per call.
Mastra traces can include prompts, completions, tool inputs, and tool outputs. Review Data Governance before enabling production traffic.

1. Install

Already have @mastra/observability and @mastra/otel-exporter? Skip. No Observability set up yet?

2. Wire the OtelExporter pointing at Agnost

Already have Mastra Observability? Append Agnost to the existing exporters array: Mastra fans traces out to every exporter in the list:
No Observability yet? Full setup:

3. Pass userId / conversationId per call

Reserved keys userId, conversationId, and threadId in tracingOptions.metadata are read by Agnost for user / session grouping.

What appears in Agnost

  • Conversations grouped by conversationId or threadId.
  • User-level analytics grouped by userId.
  • Raw logs for spans exported by Mastra.

Verify

Run one agent.generate call, then open Raw logs in Agnost. Confirm the span has your userId and conversationId.

Troubleshooting

  • Confirm the OtelExporter is included in the active Mastra observability config.
  • Confirm protocol: 'http/protobuf' and /v1/traces are used.
  • Confirm metadata keys are spelled userId, conversationId, or threadId.

References