Documentation Index
Fetch the complete documentation index at: https://docs.latitude.so/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide shows you how to integrate Latitude Telemetry into an application that uses Mastra.
Mastra has built-in observability support via @mastra/observability and @mastra/otel-exporter. It emits standard OpenTelemetry gen_ai.* spans, so you can point Mastra’s OTel exporter directly at Latitude’s OTLP ingestion endpoint — no Latitude SDK required.
You’ll keep using Mastra exactly as you do today. The exporter simply
sends your traces to Latitude alongside any other observability backend.
The Mastra integration is TypeScript only.
Requirements
- A Latitude account and API key
- A Latitude project slug
- A Node.js project that uses Mastra (
@mastra/core)
Steps
Install
npm install @mastra/observability @mastra/otel-exporter @opentelemetry/exporter-trace-otlp-proto
Configure observability
Create an OtelExporter with a custom provider pointed at Latitude’s OTLP endpoint, then pass it to Mastra’s Observability config:import { Mastra } from "@mastra/core"
import { Agent } from "@mastra/core/agent"
import { Observability } from "@mastra/observability"
import { OtelExporter } from "@mastra/otel-exporter"
const otelExporter = new OtelExporter({
provider: {
custom: {
endpoint: "https://ingest.latitude.so/v1/traces",
protocol: "http/protobuf",
headers: {
Authorization: `Bearer ${process.env.LATITUDE_API_KEY!}`,
"X-Latitude-Project": process.env.LATITUDE_PROJECT_SLUG!,
},
},
},
})
const agent = new Agent({
id: "my-agent",
name: "My Agent",
model: { provider: "OPEN_AI", name: "gpt-4o" },
instructions: "You are a helpful assistant.",
})
const mastra = new Mastra({
agents: { "my-agent": agent },
observability: new Observability({
configs: {
otel: {
serviceName: "my-mastra-app",
exporters: [otelExporter],
},
},
}),
})
Seeing Your Traces
Once connected, traces appear automatically in Latitude:
- Open your project in the Latitude dashboard
- Each execution shows input/output messages, model, token usage, latency, and errors
- Mastra agent runs, tool executions, and workflow steps appear as child spans
That’s It
No changes to your Mastra agents or tools: just configure the OTel exporter with Latitude’s endpoint and your traces flow in automatically. For more details on the OTLP endpoint and advanced options, see the OpenTelemetry Exporter page.