Skip to main content

ArthurExporter

Sends Tracing data to Arthur Engine using OpenTelemetry and OpenInference semantic conventions.

Constructor
Direct link to Constructor

new ArthurExporter(config: ArthurExporterConfig)

ArthurExporterConfig
Direct link to arthurexporterconfig

type ArthurExporterConfig = Omit<OtelExporterConfig, 'provider' | 'exporter'> & {
apiKey?: string
endpoint?: string
taskId?: string
headers?: Record<string, string>
}

Inherits from OtelExporterConfig (excluding provider and exporter), which includes:

  • timeout?: number - Export timeout in milliseconds (default: 30000)
  • batchSize?: number - Number of spans per batch (default: 512)
  • logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error' - Log level (default: WARN)
  • resourceAttributes?: Record<string, any> - Custom resource attributes

Metadata passthrough
Direct link to Metadata passthrough

Non-reserved span attributes are serialized into the OpenInference metadata payload. Add them via tracingOptions.metadata (e.g., companyId, tier). Reserved fields such as input, output, sessionId, thread/user IDs, and OpenInference IDs are excluded automatically.

Methods
Direct link to Methods

exportTracingEvent
Direct link to exporttracingevent

async exportTracingEvent(event: TracingEvent): Promise<void>

Exports a tracing event to the configured endpoint.

export
Direct link to export

async export(spans: ReadOnlySpan[]): Promise<void>

Batch exports spans using OpenTelemetry with OpenInference semantic conventions.

flush
Direct link to flush

async flush(): Promise<void>

Force flushes any buffered spans to the configured endpoint without shutting down the exporter. Useful in serverless environments where you need to ensure spans are exported before the runtime terminates.

shutdown
Direct link to shutdown

async shutdown(): Promise<void>

Flushes pending data and shuts down the client.

Usage
Direct link to Usage

Zero-Config (using environment variables)
Direct link to Zero-Config (using environment variables)

import { ArthurExporter } from '@mastra/arthur'

// Set ARTHUR_API_KEY and ARTHUR_BASE_URL (optionally ARTHUR_TASK_ID)
const exporter = new ArthurExporter()

Explicit Configuration
Direct link to Explicit Configuration

import { ArthurExporter } from '@mastra/arthur'

const exporter = new ArthurExporter({
apiKey: process.env.ARTHUR_API_KEY!,
endpoint: 'http://localhost:3030',
taskId: process.env.ARTHUR_TASK_ID, // Optional
})

OpenInference semantic conventions
Direct link to openinference-semantic-conventions

The ArthurExporter implements OpenInference Semantic Conventions for generative AI applications, providing standardized trace structure across different observability platforms.

Tags support
Direct link to Tags support

The ArthurExporter supports trace tagging for categorization and filtering. Tags are only applied to root spans and are mapped to the native OpenInference tag.tags semantic convention.

Usage
Direct link to Usage

const result = await agent.generate('Hello', {
tracingOptions: {
tags: ['production', 'experiment-v2', 'user-request'],
},
})

How Tags Are Stored
Direct link to How Tags Are Stored

Tags are stored using the OpenInference tag.tags attribute:

{
"tag.tags": ["production", "experiment-v2", "user-request"]
}