# Mastra

> Add Radiant export to the observability configuration of an existing Mastra application.

Mastra’s observability system records agent, model and tool activity. Add its OpenTelemetry exporter to send those records to Radiant while keeping the application’s existing agents, models and invocation code.

## Add the exporter

For Mastra 1.x, install the exporter and its HTTP/protobuf transport alongside the existing application:

**Terminal**

```sh
npm install @mastra/otel-exporter@1 @opentelemetry/exporter-trace-otlp-proto
```

If the application has not enabled Mastra observability yet, also install `@mastra/observability@1`. Obtain the project endpoint and key from [Set up your project](/docs/platform/set-up-your-project.md) and set:

**Application environment**

```sh
export RADIANT_TRACES_ENDPOINT='https://YOUR_INGESTION_HOST/v1/traces'
export RADIANT_INGESTION_KEY='YOUR_INGESTION_KEY'
export OTEL_SERVICE_NAME='YOUR_APPLICATION_NAME'
```

## Configure observability

Configure the exporter in the observability instance used by your application. If observability is already configured, add `OtelExporter` to its exporters list and keep the other exporters and processors. Otherwise, create the configuration below and pass it to the existing `Mastra` instance.

**Observability configuration**

```ts
import { Observability } from '@mastra/observability';
import { OtelExporter } from '@mastra/otel-exporter';


const endpoint = process.env.RADIANT_TRACES_ENDPOINT;
const key = process.env.RADIANT_INGESTION_KEY;
const serviceName = process.env.OTEL_SERVICE_NAME;
if (!endpoint || !key || !serviceName) {
  throw new Error('Set the Radiant endpoint, ingestion key and service name');
}


export const observability = new Observability({
  configs: {
    default: {
      serviceName,
      exporters: [
        new OtelExporter({
          provider: {
            custom: {
              endpoint,
              protocol: 'http/protobuf',
              headers: { Authorization: `Bearer ${key}` }
            }
          },
          signals: { traces: true, logs: false }
        })
      ]
    }
  }
});
```

Add `observability` to the existing `new Mastra({ ... })` options. Do not create another instance or replace the agents map. The existing `mastra.getAgent(...).generate(...)` call remains unchanged.

This configuration exports traces only. Mastra’s log exporter uses a different signal and endpoint; sending it to Radiant’s traces URL would not turn those logs into spans.

## Add attributes

Pass application context through `tracingOptions.metadata` on your existing agent call. Here, `messages`, `conversationId` and `release` come from your application:

**Existing agent call**

```ts
const result = await agent.generate(messages, {
  tracingOptions: {
    metadata: { threadId: conversationId, release }
  }
});
```

This metadata belongs to the root span of this call. Mastra’s exporter records `threadId` as `gen_ai.conversation.id`, which brings related runs together in [Conversations](/docs/platform/logs/search-and-filters.md#conversations). It records `release` as `mastra.metadata.release`, which you can use to filter Logs. Other metadata keys use the `mastra.metadata.` prefix; see [Mastra’s tracing options](https://mastra.ai/reference/observability/tracing/interfaces#tracingoptions).

## Record an application request

Execute a normal agent request, then open the project’s **Logs** and search for the configured service. Open the invocation to inspect its model requests and executed tools. Their payloads depend on what the observability configuration records and processes before export; retain or configure those processors for your content policy.

Call `await observability.shutdown()` during application shutdown so queued activity is exported. Keep the observability instance alive across requests.

[Mastra’s OpenTelemetry integration](https://mastra.ai/integrations/observability/opentelemetry) documents the exporter and capture pipeline. Use [tracing troubleshooting](/docs/platform/reference/telemetry.md#troubleshoot-tracing) if exported activity does not appear.
