Connect your agent
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
Section titled “Add the exporter”For Mastra 1.x, install the exporter and its HTTP/protobuf transport alongside the existing application:
npm install @mastra/otel-exporter@1 @opentelemetry/exporter-trace-otlp-protoIf the application has not enabled Mastra observability yet, also install @mastra/observability@1. Obtain the project endpoint and key from Set up your project and set:
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
Section titled “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.
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
Section titled “Add attributes”Pass application context through tracingOptions.metadata on your existing agent call. Here, messages, conversationId and release come from your application:
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. 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.
Record an application request
Section titled “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 documents the exporter and capture pipeline. Use tracing troubleshooting if exported activity does not appear.
Copyright © 2026, Radiant AI Limited.