> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Mastra

> Trace Mastra agents and workflows via its built-in OpenTelemetry exporter, no Zespan SDK required.

<Note>
  Available via: **native OpenTelemetry export** (TypeScript). This is not a Zespan SDK wrapper — see [Send traces from any OTel-instrumented app](/sdk/otel-integration#send-traces-from-any-otel-instrumented-app-no-zespan-sdk) for how the underlying endpoint works.
</Note>

[Mastra](https://mastra.ai) has a built-in OTLP exporter as part of its Observability system — point it at Zespan and every agent run, workflow step, and tool call is traced with no separate instrumentation package.

<Warning>
  Mastra's telemetry API has changed across versions (`telemetry` config → `Observability`/`OtelExporter`), and an open proposal in Mastra's repo discusses deprecating the OTel-based system in favor of a new one. Check [Mastra's current observability docs](https://mastra.ai/docs/observability/tracing/exporters/otel) for the exporter shape on the version you're running before copying this verbatim.
</Warning>

## Installation

```bash theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
npm install @mastra/core @mastra/observability @mastra/otel-exporter
```

## Setup

```typescript theme={"theme":{"light":"github-light","dark":"one-dark-pro"}}
import { Mastra } from "@mastra/core";
import { Observability } from "@mastra/observability";
import { OtelExporter } from "@mastra/otel-exporter";

export const mastra = new Mastra({
  observability: new Observability({
    configs: {
      default: {
        serviceName: "my-mastra-app",
        exporters: [
          new OtelExporter({
            provider: {
              custom: {
                endpoint: "https://api.zespan.com/v1/traces",
                protocol: "http/protobuf",
                headers: { "x-api-key": "zsp_..." },
              },
            },
          }),
        ],
      },
    },
  }),
});
```

## What gets captured

Agent runs, workflow steps, and tool calls map through the standard [OpenTelemetry GenAI semantic conventions](/sdk/otel-integration#attributes-zespan-reads) Zespan reads — model, tokens, prompts, and completions per step, connected into one trace per run.
