phoenix-cli について
Phoenix CLIは、Phoenixのデプロイに接続し、プロジェクト、トレース、スパン、セッションのデータを扱うコマンドラインツールです。プロファイル、OAuth認証、機械処理向けの出力形式を備えています。
主な機能
- 01プロジェクト、トレース、スパン、セッションの照会
- 02オブザーバビリティデータへの注釈と管理
- 03複数デプロイ用プロファイルの設定
- 04OAuthまたはAPIキーによる認証
- 05JSONおよびraw形式での出力
活用シーン
- 01期間を指定したエラートレースの抽出
- 02複数のPhoenixデプロイ間でのデータ比較
- 03クエリ結果をjqへパイプ
- 04アプリのトレース設定と検証
MCP 対応
PhoenixのリモートMCPサーバーをコーディングエージェントの設定に登録できます。セットアップではPhoenix docs MCPサーバーへの接続も可能です。
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ arize-ai/ phoenix --skill phoenix-cliインストール後、Claude Code で/phoenix-cliを入力して読み込まれたか確認します。
同梱ファイルreferences/filter-expressions.md
詳細
Phoenix CLI
呼び出し
px <resource> <action> # if installed globally
npx @arizeai/phoenix-cli <resource> <action> # no install required
CLI では、list や get などのサブコマンドを持つ単数形のリソースコマンドを使用します。
px trace list
px trace get <trace-id>
px trace annotate <trace-id>
px trace add-note <trace-id>
px trace delete <trace-identifier>
px trace-annotations delete
px span list
px span annotate <span-id>
px span add-note <span-id>
px span delete <span-identifier>
px span-annotations delete
px session list
px session get <session-id>
px session annotate <session-id>
px session add-note <session-id>
px session delete <session-id>
px session-annotations delete
px dataset list
px dataset get <name>
px dataset delete <dataset-identifier>
px experiment list
px experiment get <id>
px experiment delete <experiment-id>
px prompt list
px prompt get <prompt-identifier>
px prompt delete <prompt-identifier>
px project list
px project get <name>
px project delete <project-identifier>
px annotation-config list
px annotation-config get <identifier>
px annotation-config create
px annotation-config update <identifier>
px annotation-config delete <id>
px auth login
px auth logout
px auth status
px profile list
px profile show [name]
px profile create <name>
px profile use <name>
px profile edit <name>
px profile delete <name>
px api graphql <query>
px docs fetch
px setup
px self update
上記の delete はすべて実行が制限されています。環境変数に
PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true を設定する必要があり、-y/--yes を渡さない限り確認を求められます(px profile delete はローカル専用で、環境変数による制限なしに --yes を指定します)。環境変数が設定されていない場合、コマンドは何も削除せずに終了します。
セットアップ
export PHOENIX_ENDPOINT=http://localhost:6006
export PHOENIX_PROJECT=my-project
export PHOENIX_API_KEY=your-api-key # if auth is enabled
PHOENIX_ENDPOINT は API アクセス用のベース URL です。通常は PHOENIX_COLLECTOR_ENDPOINT と同じ URL を設定します。コレクター用の変数だけが設定されている場合、CLI はそれを API アクセスにも使用します。
対話形式でローカル利用する場合、px auth login は選択したプロファイルに OAuth セッションを保存します。このセッションは、ログインしたユーザーの権限で動作します。API キーと OAuth トークンの両方が設定されている場合、API キーが優先されます。
OAuth アクセストークンは REST、GraphQL、PXI のリクエストで自動的に更新され、ローテーションされたトークンは選択したプロファイルに保存されます。
jq にパイプするときは、常に --format raw --no-progress を使用してください。
px setup — 導入
px setup は、カレントディレクトリのアプリを Phoenix デプロイメントに接続し、.env.phoenix(モード 0600、Git で無視されます)を書き込みます。対話形式のフローは人間向けです。プロンプトを表示し、コーディングエージェントを起動して、トレースをポーリングします。エージェントから実行する場合は、必ず --no-input を渡してください。
# Register only: connection + .env.phoenix, no source changes.
px setup --no-input --endpoint http://localhost:6006 --project my-app --format raw
ヘッドレス実行にはクリーンな Git リポジトリが必要です。また、デフォルトではファイルを書き込んだ後に停止し、指示がない限りソースには変更を加えません。認証が有効な場合は、PHOENIX_API_KEY も設定してください。プロジェクトは事前に作成されていなくても構いません。最初のトレースで Phoenix が作成します。入力が不足している場合は、具体的な対処方法を示して 3 で終了します。キャンセルした場合は 2 で終了します。
アプリもインストルメントするには、レーンを指定してください。ヘッドレス実行では選択肢を尋ねるプロンプトがないため、--instrument には --agent が必要です。
px setup --no-input --instrument --agent claude --yolo --format raw
--yolo は重要です。バックグラウンドエージェントには編集を承認するターミナルがないため、これを指定しないと、トレース検証がタイムアウトするまで処理が停止します。--language python を指定すると、エージェントによる言語検出をスキップします。--docs-mcp は、引き継ぎ先のエージェントに Phoenix ドキュメントの MCP サーバーを接続します(claude では claude mcp add、cursor/opencode では設定ファイルをマージします。codex は非対応)。また、.px/docs のダウンロードをスキップし、エージェントが必要に応じてドキュメントを検索するようにします。失敗した場合はダウンロードにフォールバックします。--no-docs-mcp は、対話形式での提案を抑制します。--format raw は
{"endpoint","project","files","instrumentation","tracesVerified","tracesUrl"}
を出力します。tracesVerified を確認してください。これは API がトレースの到着を確認した場合にのみ設定され、エージェントが完了したと主張しただけでは設定されません。
待機時間が切れてもトレースが届かなかった実行は、0 ではなく 6 で終了します。設定と編集は適用されていますが、トレーシングが正常に動作していることは確認されていません。これは成功ではなく、報告すべき失敗として扱ってください。また、引き継ぎ先エージェントの終了コードや要約を判定の代わりにしないでください。--instrument を指定せずに登録した場合と、タイムアウト時のプロンプトで人間が「後で検証する」と回答した場合は、どちらも 0 で終了します。
登録のみの実行でも tracesVerified は false になるため、これだけでは「検証する対象がない」場合と「トレースが届かなかった」場合を区別できません。違いを確認する必要がある場合は、verification(verified/notVerified/deferred。検証対象がなかった場合は存在しません)を確認してください。
再実行可能な単位に分けて実行できるため、すでに登録済みのリポジトリでは質問がスキップされます。
px setup instrument --agent claude # instrument + verify only
px setup skills # install the Phoenix coding-agent skills
px setup mcp — リモート MCP サーバーを登録する
Phoenix のリモート MCP サーバー(<endpoint>/mcp)をコーディングエージェントに接続し、Phoenix のデータを照会できるようにします。エンドポイントは --endpoint、アクティブなプロファイル、または PHOENIX_ENDPOINT から推測されます。コマンドを引数なしで実行すると、スコープ(デフォルトはグローバル)、続いてエージェントの入力を求められます。--agent を指定すると、両方の入力を省略します。
px setup mcp --agent codex --no-input --format raw
px setup mcp --agent claude --local # write this repo's .mcp.json
エージェント:claude、codex、gemini、cursor、opencode、vscode。スコープは --global(デフォルト)または --local(リポジトリ)です(Codex はグローバルのみ)。デフォルトの認証方式は OAuth です(URL のみの設定で、初回使用時にブラウザーでログインします)。API キーのベアラー認証を代替手段として使う場合は、--header "Name: value" を指定します(繰り返し指定可能)。Codex では、Authorization: Bearer ${VAR} ヘッダーは bearer_token_env_var に変換されます。--format raw は {"endpoint","url","serverName","agent","scope","auth","file?"} を出力します。
認証
px auth login # browser-based OAuth login
px auth login --no-browser # print URL for SSH/headless use
px auth logout # clear OAuth tokens; leaves API keys
px auth status # check connection and authentication
px auth status --endpoint http://other:6006 # check a specific endpoint
px auth status --profile staging # check a named profile's connection
px auth status --format raw # machine-readable credential source
auth status は認証情報の取得元(flag、env、profile-key、oauth、none)を報告します。OAuth の場合は、トークンの有効期限も表示します。
保存された認証情報の取得元が oauth で、認証済みのプローブに失敗した場合、auth status は認証情報なしでもう一度だけ再試行し、サーバーが匿名アクセスを明示した場合に限り、匿名アクセスとして報告します。これにより、古くなった、または期限切れのプロファイルトークンが、OAuth から匿名アクセスに切り替わったデプロイに対する認証エラーとして報告されるのを防ぎます。
プロファイル
名前付きプロファイルを使うと、環境変数を切り替えることなく、複数の Phoenix インスタンス(ローカル、ステージング、クラウド)を切り替えられます。プロファイルは ~/.px/settings.json(または $XDG_CONFIG_HOME/px/settings.json)に保存されます。
設定の優先順位(高い順):CLI フラグ > 環境変数 > アクティブなプロファイル > 最も近い .env.phoenix ファイル > 組み込みのデフォルト。
CLI は、現在の作業ディレクトリ以下で最も近い .env.phoenix ファイルも検出します(px setup が書き込むファイルと同じです)。認証情報はひとまとまりとして解決されるため、プロセスの API キーとファイルで指定されたヘッダーが組み合わされることはありません。検出を無効にするには、PHOENIX_DISCOVER_CONFIG=false を設定します。
px profile list # list all profiles (shows active profile)
px profile show # show the active profile's settings
px profile show staging # show a named profile's settings
px profile create prod --endpoint https://app.phoenix.arize.com --api-key <key> --activate
px profile create local --endpoint http://localhost:6006 --project my-app
px profile use prod # switch the active profile
px profile edit prod # open profile JSON in $EDITOR (validates on save)
px profile delete prod --yes # delete a profile (--yes skips confirmation)
アクティブなプロファイルを変更せずに特定のプロファイルを対象にするには、任意のコマンドで --profile <name> を使用します。
px trace list --profile staging --limit 10 --format raw --no-progress | jq .
px auth status --profile prod
px profile create のオプション:--endpoint <url>、--project <name>、--api-key <key>、--header <key=value>(繰り返し指定可能)、--activate。
プロジェクト
px project list # list all projects (table view)
px project list --format raw --no-progress | jq '.[].name' # project names as JSON
px project list --name-contains prod # filter by name substring (case-insensitive)
px project get my-project --format raw --no-progress # single record by exact name
px project get my-project --format raw --no-progress | jq -r '.id' # extract project id
project list は --limit <n>(ページごとに取得するプロジェクト数)と --name-contains <filter> を受け付けます。後者は、大文字と小文字を区別しない名前の部分文字列でサーバー側のフィルタリングを行います。プロジェクト名の一部しかわからない場合は、list を grep に渡す代わりに使用してください。
project get は名前が見つからない場合、ExitCode.FAILURE(1)で終了し、--format json|raw では stderr に StructuredError {error, code: "FAILURE", hint} を出力します。
トレース
px trace list --limit 20 --format raw --no-progress | jq .
px trace list --last-n-minutes 60 --limit 20 --format raw --no-progress | jq '.[] | select(.status == "ERROR")'
px trace list --since 2025-01-15T00:00:00Z --limit 50 --format raw --no-progress | jq .
px trace list --since 2025-01-15T00:00:00Z --until 2025-01-16T00:00:00Z --limit 50 --format raw --no-progress | jq . # time range (until is exclusive)
px trace list --format raw --no-progress | jq 'sort_by(-.duration) | .[0:5]'
px trace list --include-notes --format raw --no-progress | jq '.[].notes'
px trace get <trace-id> --format raw | jq .
px trace get <trace-id> --format raw | jq '.spans[] | select(.status_code != "OK")'
px trace get <trace-id> --include-notes --format raw | jq '.notes'
px trace annotate <trace-id> --name reviewer --label pass
px trace annotate <trace-id> --name reviewer --score 0.9 --format raw --no-progress
px trace annotate <trace-id> --name reviewer --label pass --identifier "<coding-annotation-id>" # tag with a coding annotation identifier
px trace add-note <trace-id> --text "needs follow-up"
px trace add-note <trace-id> --text "needs follow-up" --identifier "<coding-annotation-id>" # tag + upsert on identifier
px trace-annotations delete --identifier "<coding-annotation-id>" --all -y # nuke every annotation tied to this coding annotation identifier
px <entity>-annotations delete には --all、または --start-time と --end-time の両方が必要です。成功すると {deleted: true, target, filter} を出力します。
トレースの JSON 形式
Trace
traceId, status ("OK"|"ERROR"), duration (ms), startTime, endTime
annotations[] (with --include-annotations, excludes note)
name, result { score, label, explanation }
notes[] (with --include-notes)
name="note", result { explanation }
rootSpan — top-level span (parent_id: null)
spans[]
name, span_kind ("LLM"|"CHAIN"|"TOOL"|"RETRIEVER"|"EMBEDDING"|"AGENT"|"RERANKER"|"GUARDRAIL"|"EVALUATOR"|"DECISION"|"UNKNOWN")
status_code ("OK"|"ERROR"|"UNSET"), parent_id, context.span_id
notes[] (with --include-notes)
name="note", result { explanation }
attributes
input.value, output.value — raw input/output
llm.model_name, llm.provider
llm.token_count.prompt/completion/total
llm.token_count.prompt_details.cache_read
llm.token_count.completion_details.reasoning
llm.input_messages.{N}.message.role/content
llm.output_messages.{N}.message.role/content
llm.invocation_parameters — JSON string (temperature, etc.)
exception.message — set if span errored
スパン
px span list --limit 20 # recent spans (table view)
px span list --last-n-minutes 60 --limit 50 # spans from last hour
px span list --since 2025-01-15T00:00:00Z --limit 50 # spans since a timestamp
px span list --since 2025-01-15T00:00:00Z --until 2025-01-16T00:00:00Z --limit 50 # time range (until is exclusive)
px span list --span-kind LLM --limit 10 # only LLM spans
px span list --status-code ERROR --limit 20 # only errored spans
px span list --name chat_completion --limit 10 # filter by span name
px span list --trace-id <id> --format raw --no-progress | jq . # all spans for a trace
px span list --span-id <id> <id> --format raw --no-progress | jq . # fetch specific spans by ID (server >= 19.6.0)
px span list --parent-id null --limit 10 # only root spans
px span list --parent-id <span-id> --limit 10 # only children of a span
px span list --include-annotations --limit 10 # include annotation scores
px span list --include-notes --limit 10 # include span notes
px span list --attribute llm.model_name:gpt-4 --limit 10 # filter by string attribute
px span list --attribute llm.token_count.total:500 --limit 10 # filter by numeric attribute
px span list --attribute 'user.id:"12345"' --limit 10 # force string match for numeric-looking value
px span list --attribute session.id:sess:abc:123 --limit 20 # colon in value OK (split on first colon only)
px span list --attribute llm.model_name:gpt-4 --attribute session.id:abc --limit 10 # AND multiple filters
px span list output.json --limit 100 # save to JSON file
px span list --format raw --no-progress | jq '.[] | select(.status_code == "ERROR")'
px span annotate <span-id> --name reviewer --label pass
px span annotate <span-id> --name checker --score 1 --annotator-kind CODE
px span annotate <span-id> --name reviewer --label pass --identifier "<coding-annotation-id>" # tag with a coding annotation identifier
px span add-note <span-id> --text "verified by agent"
px span add-note <span-id> --text "verified by agent" --identifier "<coding-annotation-id>" # tag + upsert on identifier
px span-annotations delete --identifier "<coding-annotation-id>" --all -y # nuke every annotation tied to this coding annotation identifier
span list は start_time ではなく、取り込み順(新しい順)で並べ替えます。遅れて到着するスパン(バックフィル、リプレイ)では、両者の順序が異なります。start_time で並べ替えるには(サーバー >= 20.16.0)、REST を呼び出し、next_cursor のページ間で sort/order を固定してください。
curl -s -H "Authorization: Bearer $PHOENIX_API_KEY" \
"$PHOENIX_ENDPOINT/v1/projects/my-project/spans?sort=start_time&order=desc&limit=20"
スパンの JSON 形式
Span
name, span_kind ("LLM"|"CHAIN"|"TOOL"|"RETRIEVER"|"EMBEDDING"|"AGENT"|"RERANKER"|"GUARDRAIL"|"EVALUATOR"|"DECISION"|"UNKNOWN")
status_code ("OK"|"ERROR"|"UNSET"), status_message
context.span_id, context.trace_id, parent_id
start_time, end_time
attributes
input.value, output.value — raw input/output
llm.model_name, llm.provider
llm.token_count.prompt/completion/total
llm.input_messages.{N}.message.role/content
llm.output_messages.{N}.message.role/content
llm.invocation_parameters — JSON string (temperature, etc.)
exception.message — set if span errored
annotations[] (with --include-annotations, excludes note)
name, result { score, label, explanation }
notes[] (with --include-notes)
name="note", result { explanation }
セッション
px session list --limit 10 --format raw --no-progress | jq .
px session list --order asc --format raw --no-progress | jq '.[].session_id'
px session list --include-annotations --include-notes --format raw --no-progress | jq '.[].notes'
px session get <session-id> --format raw | jq .
px session get <session-id> --include-annotations --format raw | jq '.session.annotations'
px session get <session-id> --include-notes --format raw | jq '.session.notes'
px session annotate <session-id> --name reviewer --label pass
px session annotate <session-id> --name reviewer --score 0.9 --format raw --no-progress
px session annotate <session-id> --name reviewer --label pass --identifier "<coding-annotation-id>" # tag with a coding annotation identifier
px session add-note <session-id> --text "verified by agent"
px session add-note <session-id> --text "verified by agent" --identifier "<coding-annotation-id>" # tag + upsert on identifier
px session-annotations delete --identifier "<coding-annotation-id>" --all -y # nuke every annotation tied to this coding annotation identifier
px session delete <session-id> -y # requires PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true
session list にフィルターフラグはありません。エラー数、トークン合計、ツールの使用状況、アノテーションラベルなどの形状でセッションを選択するには、GraphQL を通じてセッションフィルター式言語を使用してください(セッションフィルター式を参照)。
セッションの JSON 形式
SessionData
id, session_id, project_id
start_time, end_time
token_count_prompt, token_count_completion, token_count_total — cumulative across all LLM spans in the session (int, default 0)
annotations[] (with --include-annotations, excludes note)
name, result { score, label, explanation }
notes[] (with --include-notes)
name="note", result { explanation }
traces[]
id, trace_id, start_time, end_time
データセット/実験/プロンプト
px dataset list --format raw --no-progress | jq '.[].name'
px dataset get <name> --format raw | jq '.examples[] | {input, output: .expected_output}'
px dataset get <name> --split train --format raw | jq . # filter by split
px dataset get <name> --version <version-id> --format raw | jq .
px experiment list --dataset <name> --format raw --no-progress | jq '.[] | {id, name, failed_run_count}'
px experiment get <id> --format raw --no-progress | jq '.[] | select(.error != null) | {input, error}'
px prompt list --format raw --no-progress | jq '.[].name'
px prompt get <name> --format text --no-progress # plain text, ideal for piping to AI
アノテーション設定
完全な CRUD に対応しています:list、get、create、update、delete。タイプは CATEGORICAL(ラベルと任意のスコア)、CONTINUOUS(数値範囲)、FREEFORM(自由記述)です。
px annotation-config list # all configs (table view)
px annotation-config list --format raw --no-progress | jq -r '.[].name' # config names as JSON
px annotation-config get response-quality --format raw --no-progress # one config by name or ID
# create — categorical (scored labels), continuous (numeric range), or freeform (free text)
px annotation-config create --type CATEGORICAL --name response-quality --value good=1 --value bad=0
px annotation-config create --type CONTINUOUS --name confidence --lower-bound 0 --upper-bound 1
px annotation-config create --type FREEFORM --name reviewer-notes --description 'Free-form reviewer feedback'
# update by name or ID — only the fields you pass change; type is immutable
px annotation-config update response-quality --name answer-quality --optimization-direction MAXIMIZE
px annotation-config update response-quality --value good=1 --value acceptable=0.5 --value bad=0
px annotation-config update response-quality --description "Updated" --format raw --no-progress | jq -r '.id'
# delete by ID — requires PHOENIX_CLI_DANGEROUSLY_ENABLE_DELETES=true; --yes skips the prompt
px annotation-config delete QW5ub3RhdGlvbkNvbmZpZzoxMjM= --yes
カテゴリ値は create と update で同じ方法で指定します。繰り返し指定できる --value label[=score](スコアは任意)、または単一の --values '<json>' ペイロードを使います。両者は同時に指定できません。update は既存の設定を取得し、指定したフラグをマージして、PUT /v1/annotation_configs/{id} で完全な本文を書き戻します。少なくとも 1 つのフィールドフラグが必要です。その他のタイプ固有フラグは、--lower-bound/--upper-bound(CONTINUOUS/FREEFORM)、--threshold(FREEFORM)です。無効な入力(不正なフラグ、タイプの不一致、不正な形式の値)があると、3(INVALID_ARGUMENT)で終了し、raw/json モードでは stderr に {error, code, hint?} 形式の JSON エンベロープを出力します。get/create/update は設定オブジェクトを出力します(raw/json では配列ではなく単一のオブジェクト)。
GraphQL
上記のコマンドでは対応していない、その場限りのクエリに使用します。出力は {"data": {...}} です。
px api graphql '{ projectCount datasetCount promptCount evaluatorCount }'
px api graphql '{ projects { edges { node { name traceCount tokenCountTotal } } } }' | jq '.data.projects.edges[].node'
px api graphql '{ datasets { edges { node { name exampleCount experimentCount } } } }' | jq '.data.datasets.edges[].node'
px api graphql '{ evaluators { edges { node { name kind } } } }' | jq '.data.evaluators.edges[].node'
# evaluator kind values: "LLM" | "CODE" | "BUILTIN"
# CODE = server-side code evaluator running in a sandbox; BUILTIN = pre-built server evaluator
# Introspect any type
px api graphql '{ __type(name: "Project") { fields { name type { name } } } }' | jq '.data.__type.fields[]'
主なルートフィールド:projects、getProjectByName(name:)、datasets、prompts、evaluators、projectCount、datasetCount、promptCount、evaluatorCount、viewer。
getProjectByName(name:) は 1 つのプロジェクトを対象にします。projects(first: 1) は任意のプロジェクトを選択します。traces 接続はありません。トレースを一覧表示するには、UI のトレーステーブルと同様に、ルートスパンを保持する filterCondition: "parent_span is None" を指定して spans をクエリします。下記のフィルター式を参照してください。
フィルター式
spans、sessions、およびプロジェクトの集計には、フィルター条件を指定できます。これはサーバー側でコンパイルされる Python のブール式です。言語は 3 種類あり、引数によって使用する言語が決まります。条件を記述する前にreferences/filter-expressions.mdをお読みください。各言語の語彙、演算子、コンパイル済みの例がすべて記載されています。
| 引数 | 対象 | 名前の参照元 |
|---|---|---|
filterCondition | 個々のスパン | リファレンスの網羅的な表 |
traceFilterCondition | トレース全体 | traceFilterVocabulary |
sessionFilterCondition | セッション | sessionFilterVocabulary |
ルートスパン。 traces 接続もルートスパン引数もありません。filterCondition: "parent_span is None" は、親が受信されなかった孤立したスパンも含めてルートスパンを保持します。これは UI のトレーステーブルで実行される条件です。parent_id is None は、親 ID のないスパンのみを保持します。通常、ルートスパンはトレースごとに 1 つであり、どちらの条件もほかのフィルターと組み合わせられます。
px api graphql '{
getProjectByName(name: "default") { spans(
first: 20
filterCondition: "parent_id is None and status_code == \"ERROR\""
sort: { col: startTime, dir: desc }
) { edges { node { spanId name latencyMs } } } }
}' | jq '.data.getProjectByName.spans.edges[].node'
アノテーション。 アクセサーによって対象レベルが決まり、誤ったレベルを指定すると何も一致しません。
| アクセサー | アノテーションの対象 | 書き込み元 |
|---|---|---|
annotations["name"] | スパン自体 | px span annotate、px span add-note |
trace_annotations["name"] | スパンの親トレース | px trace annotate、px trace add-note |
session_annotations["name"] | セッション(セッションフィルターのみ) | px session annotate、px session add-note |
px api graphql '{
getProjectByName(name: "default") { spans(
first: 20
filterCondition: "parent_id is None and trace_annotations[\"quality\"].label == \"poor\""
) { edges { node { spanId name } } } }
}' | jq '.data.getProjectByName.spans.edges[].node'
トレース。 traceFilterCondition は、一致するトレースのスパンを保持し、filterCondition と組み合わせて使用できます。
px api graphql '{
getProjectByName(name: "default") { spans(
first: 20
filterCondition: "parent_id is None"
traceFilterCondition: "error_count > 0 and latency_ms > 1000"
) { edges { node { spanId name latencyMs } } } }
}' | jq '.data.getProjectByName.spans.edges[].node'
セッション。 px session list にはフィルターフラグがないため、条件でセッションを選択するには GraphQL を使用します。
px api graphql '{
projects(first: 1) { edges { node { sessions(
first: 10
sessionFilterCondition: "num_traces > 5 and any(span.status_code == \"ERROR\" for span in spans)"
) { edges { node { sessionId numTraces numTracesWithError } } } } } }
}' | jq '.data.projects.edges[0].node.sessions.edges[].node'
名前の確認と検証。 語彙はコンパイラー自体のバインディングから生成されるため、常にコンパイル可能な内容と一致します。
px api graphql '{ projects(first: 1) { edges { node { traceFilterVocabulary {
name type category description iterableName } } } } }' \
| jq '.data.projects.edges[0].node.traceFilterVocabulary[] | {name, type, category}'
px api graphql '{ projects(first: 1) { edges { node {
validateSpanFilterCondition(condition: "parent_id is None") { isValid errorMessage }
validateTraceFilterCondition(condition: "error_count > 0") { isValid errorMessage }
validateSessionFilterCondition(condition: "num_traces > 5") { isValid errorMessage }
} } } }'
両方のレベルを受け付けるフィールド(例:Project.recordCount)では、sessionFilterCondition と filterCondition は同時に指定できません。
ドキュメント
コーディングエージェントがローカルで使用できるように、Phoenix のドキュメントを Markdown 形式でダウンロードします。
px docs fetch # fetch default workflow docs to .px/docs
px docs fetch --workflow tracing # fetch only tracing docs
px docs fetch --workflow tracing --workflow evaluation
px docs fetch --dry-run # preview what would be downloaded
px docs fetch --refresh # clear .px/docs and re-download
px docs fetch --output-dir ./my-docs # custom output directory
主なオプション:--workflow(繰り返し指定可能。値:tracing、evaluation、datasets、prompts、integrations、sdk、self-hosting、all)、--dry-run、--refresh、--output-dir(デフォルト .px/docs)、--workers(デフォルト 10)。