> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Arthur exporter [Arthur](https://arthur.ai/) は、オープンソースの [Arthur Engine](https://github.com/arthur-ai/arthur-engine) を通じて、AI アプリケーション向けの Observability および評価プラットフォームを提供します。Arthur exporter は、OpenTelemetry と [OpenInference](https://github.com/Arize-ai/openinference/tree/main/spec) のセマンティック規約を使用して Trace を送信します。 ## インストール **npm**: ```bash npm install @mastra/arthur@latest ``` **pnpm**: ```bash pnpm add @mastra/arthur@latest ``` **Yarn**: ```bash yarn add @mastra/arthur@latest ``` **Bun**: ```bash bun add @mastra/arthur@latest ``` ## 設定 ### 前提条件 1. **Arthur Engine インスタンス**: [Docker Compose デプロイガイド](https://docs.arthur.ai/docs/arthur-genai-engine-docker-compose-deployment-guide)に従って Arthur Engine を起動する 2. **API key**: `http://localhost:3030` の Arthur Engine UI から [API key を生成する](https://docs.arthur.ai/docs/api-keys-management) 3. **Task ID**(任意): Trace を特定の Task にルーティングするために [Task を作成する](https://docs.arthur.ai/docs/create-a-task) ### Task のルーティング Arthur Engine は、次の2つの方法で Trace を Task に関連付けます。 - **Service name を使用**: Observability 設定で `serviceName` を設定します。Arthur Engine は、その名前と一致する Task に Trace を自動的にルーティングし、必要な場合は Task を作成します。 - **Task ID を使用**: 既存の `taskId` を exporter に渡し、Trace を特定の Task に直接送信します。 両方を指定した場合は、`taskId` が優先されます。 ### 環境変数 ```bash # Required ARTHUR_API_KEY=your-api-key ARTHUR_BASE_URL=http://localhost:3030 # Optional - route traces to a pre-existing task by ID ARTHUR_TASK_ID=your-task-id ``` ### ゼロコンフィグセットアップ 環境変数を設定すると、設定を渡さずに exporter を使用できます。 ```typescript import { Mastra } from '@mastra/core' import { Observability } from '@mastra/observability' import { ArthurExporter } from '@mastra/arthur' export const mastra = new Mastra({ observability: new Observability({ configs: { arthur: { serviceName: 'my-service', exporters: [new ArthurExporter()], }, }, }), }) ``` ### 明示的な設定 認証情報を直接渡すこともできます(環境変数より優先されます)。 ```typescript import { Mastra } from '@mastra/core' import { Observability } from '@mastra/observability' import { ArthurExporter } from '@mastra/arthur' export const mastra = new Mastra({ observability: new Observability({ configs: { arthur: { serviceName: 'my-service', exporters: [ new ArthurExporter({ apiKey: process.env.ARTHUR_API_KEY!, endpoint: process.env.ARTHUR_BASE_URL!, taskId: process.env.ARTHUR_TASK_ID, }), ], }, }, }), }) ``` ## 設定オプション ### 完全な設定 ```typescript new ArthurExporter({ // Arthur Configuration apiKey: 'your-api-key', // Required endpoint: 'http://localhost:3030', // Required taskId: 'your-task-id', // Optional // Optional OTLP settings headers: { 'x-custom-header': 'value', // Additional headers for OTLP requests }, // Debug and performance tuning logLevel: 'debug', // Logging: debug | info | warn | error batchSize: 512, // Batch size before exporting spans timeout: 30000, // Timeout in ms before exporting spans // Custom resource attributes resourceAttributes: { 'deployment.environment': process.env.NODE_ENV, 'service.version': process.env.APP_VERSION, }, }) ``` ### カスタム metadata 予約されていない Span 属性は、OpenInference の `metadata` ペイロードにシリアライズされ、Arthur に表示されます。これらは `tracingOptions.metadata` で追加できます。 ```ts await agent.generate(input, { tracingOptions: { metadata: { companyId: 'acme-co', tier: 'enterprise', }, }, }) ``` `input`、`output`、`sessionId`、Thread/User ID、OpenInference ID などの予約フィールドは、自動的に除外されます。 ## OpenInference のセマンティック規約 この exporter は、生成 AI アプリケーション向けの [OpenInference Semantic Conventions](https://github.com/Arize-ai/openinference/tree/main/spec) を実装し、異なる Observability プラットフォーム間で標準化された Trace 構造を提供します。 ## 関連項目 - [Tracing の概要](https://mastra.zisheng.pro/ja/docs/observability/tracing/overview) - [ArthurExporter リファレンス](https://mastra.zisheng.pro/ja/reference/observability/tracing/exporters/arthur) - [Arthur Engine ドキュメント](https://docs.arthur.ai/) - [Arthur Engine リポジトリ](https://github.com/arthur-ai/arthur-engine) - [OpenInference 仕様](https://github.com/Arize-ai/openinference/tree/main/spec)