Documentation Index
Fetch the complete documentation index at: https://docs.agnost.ai/llms.txt
Use this file to discover all available pages before exploring further.
Mastra ships an OtelExporter 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?
npm install @mastra/observability @mastra/otel-exporter
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:
import { OtelExporter } from '@mastra/otel-exporter';
const agnostExporter = new OtelExporter({
provider: {
custom: {
endpoint: 'https://otel.agnost.ai/v1/traces',
headers: { 'X-Agnost-Org-ID': process.env.AGNOST_ORG_ID! },
protocol: 'http/protobuf',
},
},
});
// Inside your existing Observability config:
exporters: [
// ...your existing exporters,
agnostExporter,
]
No Observability yet? Full setup:
import { Mastra } from '@mastra/core';
import { Observability } from '@mastra/observability';
import { OtelExporter } from '@mastra/otel-exporter';
export const mastra = new Mastra({
agents: { agent },
observability: new Observability({
configs: {
default: {
serviceName: 'my-mastra-app',
exporters: [
new OtelExporter({
provider: {
custom: {
endpoint: 'https://otel.agnost.ai/v1/traces',
headers: { 'X-Agnost-Org-ID': process.env.AGNOST_ORG_ID! },
protocol: 'http/protobuf',
},
},
}),
],
},
},
}),
});
3. Pass userId / conversationId per call
await agent.generate('Hello', {
tracingOptions: {
metadata: {
userId: 'user-42',
conversationId: 'conv-abc123',
},
},
});
Reserved keys userId, conversationId, and threadId in tracingOptions.metadata are read by Agnost for user / session grouping.
References