跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

ArizeExporter

Sends Tracing data to Arize Phoenix or Arize AX, as well as any OpenTelemetry-compatible observability platform that supports OpenInference semantic conventions.

Constructor
Constructor的直接链接

new ArizeExporter(config: ArizeExporterConfig)

ArizeExporterConfig
arizeexporterconfig的直接链接

type ArizeExporterConfig = Omit<OtelExporterConfig, 'provider'> & {
// Phoenix / OpenTelemetry configuration
endpoint?: string
apiKey?: string

// Arize AX configuration
spaceId?: string

// Common configuration
projectName?: string
headers?: Record<string, string>
}

Inherits from OtelExporterConfig (excluding provider), 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
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
Methods的直接链接

exportTracingEvent
exporttracingevent的直接链接

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

Exports a tracing event to the configured endpoint.

export
export的直接链接

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

Batch exports spans using OpenTelemetry with OpenInference semantic conventions.

flush
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
shutdown的直接链接

async shutdown(): Promise<void>

Flushes pending data and shuts down the client.

Usage
Usage的直接链接

Zero-Config (using environment variables)
Zero-Config (using environment variables)的直接链接

import { ArizeExporter } from '@mastra/arize'

// For Phoenix: Set PHOENIX_COLLECTOR_ENDPOINT, PHOENIX_API_KEY, PHOENIX_PROJECT_NAME
// For Arize AX: Set ARIZE_SPACE_ID, ARIZE_API_KEY, ARIZE_PROJECT_NAME
const exporter = new ArizeExporter()

Phoenix Configuration
Phoenix Configuration的直接链接

import { ArizeExporter } from '@mastra/arize'

const exporter = new ArizeExporter({
endpoint: 'http://localhost:6006/v1/traces',
apiKey: process.env.PHOENIX_API_KEY, // Optional for local Phoenix
projectName: 'my-ai-project',
})

Arize AX Configuration
Arize AX Configuration的直接链接

import { ArizeExporter } from '@mastra/arize'

const exporter = new ArizeExporter({
spaceId: process.env.ARIZE_SPACE_ID!,
apiKey: process.env.ARIZE_API_KEY!,
projectName: 'my-ai-project',
})

OpenInference semantic conventions
openinference-semantic-conventions的直接链接

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

Tags support
Tags support的直接链接

The ArizeExporter 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
Usage的直接链接

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

How Tags Are Stored
How Tags Are Stored的直接链接

Tags are stored using the OpenInference tag.tags attribute:

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