メインコンテンツへ移動

ArthurExporter

OpenTelemetry と OpenInference セマンティック規約を使用して、Tracing データを Arthur Engine へ送信します。

コンストラクター
コンストラクターへの直接リンク

new ArthurExporter(config: ArthurExporterConfig)

ArthurExporterConfig
arthurexporterconfigへの直接リンク

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

OtelExporterConfigproviderexporter を除く)を継承し、次の項目を含みます。

  • timeout?: number - エクスポートのタイムアウト(ミリ秒、デフォルト:30000)
  • batchSize?: number - バッチあたりの Span 数(デフォルト:512)
  • logLevel?: LogLevel | 'debug' | 'info' | 'warn' | 'error' - ログレベル(デフォルト:WARN)
  • resourceAttributes?: Record<string, any> - カスタムリソース属性

メタデータの引き渡し
メタデータの引き渡しへの直接リンク

予約されていない Span 属性は OpenInference の metadata ペイロードにシリアライズされます。tracingOptions.metadata(例:companyIdtier)から追加します。inputoutputsessionId、thread/user ID、OpenInference ID などの予約フィールドは自動的に除外されます。

メソッド
メソッドへの直接リンク

exportTracingEvent
exporttracingeventへの直接リンク

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

Tracing イベントを設定済みのエンドポイントへエクスポートします。

export
exportへの直接リンク

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

OpenInference セマンティック規約に従い、OpenTelemetry を使用して Span をバッチエクスポートします。

flush
flushへの直接リンク

async flush(): Promise<void>

exporter をシャットダウンせず、バッファー内のすべての Span を設定済みエンドポイントへ強制的にフラッシュします。ランタイム終了前に Span が確実にエクスポートされるようにする必要がある、サーバーレス環境で役立ちます。

shutdown
shutdownへの直接リンク

async shutdown(): Promise<void>

保留中のデータをフラッシュし、クライアントをシャットダウンします。

使用方法
使用方法への直接リンク

ゼロコンフィグ(環境変数を使用)
ゼロコンフィグ(環境変数を使用)への直接リンク

import { ArthurExporter } from '@mastra/arthur'

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

明示的な設定
明示的な設定への直接リンク

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 セマンティック規約
openinference-semantic-conventionsへの直接リンク

ArthurExporter は OpenInference セマンティック規約 を生成 AI アプリケーション向けに実装し、異なる Observability プラットフォーム間で標準化された Trace 構造を提供します。

タグのサポート
タグのサポートへの直接リンク

ArthurExporter は分類とフィルタリングのための Trace タグ付けをサポートします。タグはルート Span にのみ適用され、OpenInference ネイティブの tag.tags セマンティック規約にマッピングされます。

使用方法
使用方法への直接リンク

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

タグの保存方法
タグの保存方法への直接リンク

タグは OpenInference の tag.tags 属性を使用して保存されます:

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