Agents CLI 智能体可观测性
google-agents-cli-observability
当用户想要『设置追踪(tracing)』『监控我的智能体』『配置日志记录』『添加可观测性』『调试生产流量』,或需要有关监控已部署智能体(包括 ADK(Agent Development Kit)智能体)的指导时,应使用本技能。涵盖 Cloud Trace、提示-响应日志(prompt-response logging)、BigQuery Agent Analytics、第三方集成(AgentOps、Phoenix、MLflow 等)和故障排查。属于 agents-cli 技能套件。不用于部署设置(使用 google-agents-cli-deploy)或 API 代码模式(使用 google-agents-cli-adk-code)。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-12
- Stars
- ★ 6.3k
- Forks
- 731
01 前言 Front Matter
- name
- google-agents-cli-observability
- metadata
- { "author": "Google", "license": "Apache-2.0", "version": "1.14.0", "requires": { "bins": [ "agents-cli" ], "install": "uv tool install google-agents-cli" } }
- description
- This skill should be used when the user wants to "set up tracing", "monitor my agent", "configure logging", "add observability", "debug production traffic", or needs guidance on monitoring deployed agents, including ADK (Agent Development Kit) agents. Covers Cloud Trace, prompt-response logging, BigQuery Agent Analytics, third-party integrations (AgentOps, Phoenix, MLflow, etc.), and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment setup (use google-agents-cli-deploy) or API code patterns (use google-agents-cli-adk-code).
02 资源文件 4
- 参考文档references/adk-docs.md445 B
- 参考文档references/bigquery-agent-analytics.md1.6 KB
- 参考文档references/cloud-trace-and-logging.md8.2 KB
- 参考文档references/feedback-mechanism.md3.9 KB
03 SKILL.md 正文
Observability Guide
Cloud Trace works out of the box — no infrastructure needed. Prompt-response logging and BigQuery Agent Analytics require Terraform-provisioned infrastructure (service account, GCS bucket, BigQuery dataset). Run
agents-cli infra single-project --apply --project PROJECT_IDto provision these resources. Go projects get the BigQuery telemetry stack too; the GCS completion upload behind prompt-response logging and the BigQuery Agent Analytics plugin are Python only. Seereferences/cloud-trace-and-logging.mdfor details, env vars, and verification commands. If your project isn't scaffolded yet, see/google-agents-cli-scaffoldfirst.
Deployment order
| Do you want Terraform-managed observability? | Action |
|---|---|
| No | Run agents-cli deploy directly (works for all targets). |
| Yes | Run agents-cli infra single-project --apply first, then agents-cli deploy. |
If you already ran agents-cli deploy imperatively:
Do not apply Terraform afterward. For Agent Runtime in Gemini platform, Terraform owns the whole engine (service account, deployment spec, env vars), so a later apply can't be reconciled without taking over the resource.
Either delete the deployment and start over, or keep the SDK-deployed instance — skip infra single-project and set the observability env vars by re-running agents-cli deploy --update-env-vars "KEY=VALUE,..."; deploy matches the existing Reasoning Engine by display name and updates it in place, preserving env vars set outside the deploy. You must also grant its service account the telemetry IAM roles the Terraform module would otherwise provision: roles/storage.admin (write completions to the logs bucket), roles/logging.logWriter, roles/cloudtrace.agent, plus roles/bigquery.dataOwner + roles/bigquery.jobUser when scaffolded with --bq-analytics. The full set lives in deployment/terraform/single-project/iam.tf (from app_sa_roles) and telemetry.tf. Terraform-managed env vars aren't available in this mode.
Reference Files
| File | Contents |
|---|---|
references/cloud-trace-and-logging.md |
Scaffolded project details — Terraform-provisioned resources, environment variables, verification commands, enabling/disabling locally |
references/bigquery-agent-analytics.md |
BQ Agent Analytics plugin — enabling, key features, GCS offloading, tool provenance |
references/adk-docs.md |
ADK: adk.dev pages to fetch for detail beyond this skill |
references/feedback-mechanism.md |
Adding a user-feedback endpoint — request model, structured logging, log sink → BigQuery |
Observability Tiers
Choose the right level of observability based on your needs:
| Tier | What It Does | Scope | Default State | Best For |
|---|---|---|---|---|
| Cloud Trace | Distributed tracing — execution flow, latency, errors via OpenTelemetry spans | All templates, all environments | Always enabled | Debugging latency, understanding agent execution flow |
| Prompt-Response Logging | GenAI interactions exported to GCS, BigQuery, and Cloud Logging | Scaffolded ADK Python and Claude projects | Disabled locally, enabled when deployed | Auditing LLM interactions, compliance |
| BigQuery Agent Analytics | Structured agent events (LLM calls, tool use, outcomes) to BigQuery | ADK Python agents with the plugin enabled; Claude template agents | Opt-in (--bq-analytics at scaffold time) |
Conversational analytics, custom dashboards, LLM-as-judge evals |
| Third-Party Integrations | External observability platforms (AgentOps, Phoenix, MLflow, etc.) | Any OpenTelemetry-instrumented agent | Opt-in, per-provider setup | Team collaboration, specialized visualization, prompt management |
Ask the user which tier(s) they need — they can be combined. Cloud Trace is always on; the others are additive.
Cloud Trace
Scaffolded agents use OpenTelemetry to emit distributed traces. Every agent invocation produces spans that track the full execution flow.
Span Hierarchy
ADK projects. These are ADK's span names; other frameworks emit their own (
generate_contentcomes from the shared google-genai instrumentor either way).
invoke_workflow (top-level run)
└── invoke_agent (one per agent in the chain)
├── call_llm (model request)
│ └── generate_content (underlying GenAI model call)
└── execute_tool (tool execution)
Setup by Deployment Type
| Deployment | Setup |
|---|---|
| Agent Runtime | Automatic — exporters wired at startup, gated on GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY (set by deploy); exports to Cloud Trace/Logging + the Agent Runtime page in the Google Cloud console |
| Cloud Run / GKE (scaffolded) | Automatic — exporters wired at startup, exports to Cloud Trace/Logging |
| Cloud Run / GKE (manual) | Configure OpenTelemetry exporter in your app |
| Local dev | Works with agents-cli playground; traces visible in Cloud Console |
Wired at app startup — ADK Python: get_fast_api_app(otel_to_cloud=True) in app/fast_api_app.py; ADK Go: setupObservability() in observability.go; other templates call their own. references/cloud-trace-and-logging.md has the details.
View traces: Cloud Console → Trace → Trace explorer
ADK: for detailed setup instructions (Agent Runtime CLI/SDK, Cloud Run, custom deployments), fetch https://adk.dev/integrations/cloud-trace/index.md.
Prompt-Response Logging
Captures GenAI interactions and exports to GCS (JSONL) and BigQuery (via log sinks + external tables). Content is governed by two independent tiers; the net Terraform-deploy default is full content in GCS/BigQuery, none in traces:
| Tier | Captures | Controlled by | Default (Terraform deploy) |
|---|---|---|---|
| GCS/BigQuery completions | Full prompts/responses (the prompt-response logging feature) | OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK=upload + LOGS_BUCKET_NAME |
On — full content |
| Trace spans / Cloud Logging events | Span/event content | OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT (plus ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS=false, ADK Python only) |
Off — NO_CONTENT |
The tiers are independent: GCS/BigQuery uploads capture full content whenever their upload vars are set and do not honor OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT, which governs the traces/events tier only.
ADK Python reads it as the experimental-semconv enum:
NO_CONTENT— no content in spans/events (scaffolded default)EVENT_ONLY— content in Cloud Logging eventsSPAN_ONLY/SPAN_AND_EVENT— content in trace spanstrue/false— invalid; fall back toNO_CONTENT
ADK Go reads the same variable as a boolean: "1" or "true" capture content, every other
value — including the enum members above — elides it.
For the full mechanics (semconv opt-in, declarative Terraform config, env-var table, enabling/disabling, verification commands), see references/cloud-trace-and-logging.md. For ADK logging docs (log levels, configuration, debugging), fetch https://adk.dev/observability/logging/index.md.
BigQuery Agent Analytics Plugin
ADK projects. Optional ADK plugin that logs structured agent events to BigQuery. Enable with
--bq-analyticsat scaffold time. Seereferences/bigquery-agent-analytics.mdfor details.
Third-Party Integrations
Many third-party observability platforms can ingest agent telemetry (via OpenTelemetry or custom instrumentation). The table below covers common ones; the full list is larger (see the pointer below it).
| Platform | Key Differentiator | Setup Complexity | Self-Hosted Option |
|---|---|---|---|
| AgentOps | Session replays, 2-line setup, replaces native telemetry | Minimal | No (SaaS) |
| Arize AX | Commercial platform, production monitoring, evaluation dashboards | Low | No (SaaS) |
| Phoenix | Open-source, custom evaluators, experiment testing | Low | Yes |
| MLflow | OTel traces to MLflow Tracking Server, span tree visualization | Medium (needs SQL backend) | Yes |
| Monocle | 1-call setup, VS Code Gantt chart visualizer | Minimal | Yes (local files) |
| Weave | W&B platform, team collaboration, timeline views | Low | No (SaaS) |
| Freeplay | Prompt management + evals + observability in one platform | Low | No (SaaS) |
Ask the user which platform they prefer — present the trade-offs and let them choose. ADK: fetch a platform's setup page at https://adk.dev/integrations/<slug>/index.md (slugs for the table above: agentops, arize-ax, phoenix, mlflow-tracing, monocle, weave, freeplay); ADK has more observability integrations (Datadog, Galileo, LangWatch, Latitude, Future AGI, Respan, Zespan, …) — browse the complete, current list at https://adk.dev/integrations/ (observability topic). On other frameworks the OpenTelemetry-based platforms still work, but follow the platform's own setup docs.
Troubleshooting
| Issue | Solution |
|---|---|
| No traces in Cloud Trace | Verify telemetry setup runs at startup and the SA has the cloudtrace.agent role. ADK Python: fast_api_app.py uses get_fast_api_app(otel_to_cloud=True); ADK Go: observability.go build the exporter manually. Agent Runtime additionally gates this on GOOGLE_CLOUD_AGENT_ENGINE_ENABLE_TELEMETRY. |
| Prompt-response data not appearing | Check LOGS_BUCKET_NAME is set; verify SA has storage.objectCreator on the bucket; check app logs for telemetry setup warnings |
| Content in traces/events (unwanted) | ADK Python: OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=NO_CONTENT keeps content out of spans/events. ADK Go: any value other than 1/true does, so unset it or set false. NOTE: GCS/BigQuery completions still capture full content — to stop that, remove LOGS_BUCKET_NAME/OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK (drop the upload block in service.tf) |
| BigQuery Analytics not logging | ADK Python: verify the plugin is configured in app/agent.py; Claude: check the startup log for a BigQuery Agent Analytics warning. Both: check BQ_ANALYTICS_DATASET_ID env var is set |
| Third-party integration not capturing spans | Check provider-specific env vars (API keys, endpoints); some providers (AgentOps) replace native telemetry |
| Traces missing tool spans | ADK: tool execution spans appear under execute_tool (other frameworks use their own span names) — check trace explorer filters |
| High telemetry costs | Turn content capture off (NO_CONTENT in Python, false in Go); reduce BigQuery retention; disable unused tiers |
Related Skills
/google-agents-cli-deploy— Deployment targets, CI/CD pipelines, and production workflows/google-agents-cli-workflow— Development workflow, coding guidelines, and operational rules/google-agents-cli-adk-code— ADK API quick reference for writing agent code, Python and Go
04 同仓库更多 Skills
ADK 智能体开发工作流
google-agents-cli-workflow
当用户想要“开发智能体”“使用 ADK 构建智能体”“在本地运行智能体”“调试智能体代码”“测试智能体”“部署智能体”“发布智能体”“监控智能体”,或需要 ADK(Agent Development Kit,智能体开发工具包)开发生命周期与编码规范时,应使用本技能。它是构建 ADK 智能体的入口。始终处于激活状态——提供完整工作流(搭建脚手架、构建、评估、部署、发布、观测)、代码保留规则、模型选择指南,以及 ADK 或任何智能体开发的故障排查步骤。
agents-cli 智能体项目脚手架
google-agents-cli-scaffold
当用户想要“创建智能体项目”、“启动新的 ADK 项目”、“帮我构建一个新智能体”、“为项目添加 CI/CD”、“添加部署”、“增强我的项目”或“升级我的项目”时,应使用本技能。属于 agents-cli 技能套件。涵盖 `agents-cli scaffold create`、`scaffold enhance` 和 `scaffold upgrade` 命令、模板选项、部署目标以及原型优先(prototype-first)的工作流程。请勿用于编写智能体代码(ADK 项目请使用 google-agents-cli-adk-code)或部署操作(请使用 google-agents-cli-deploy)。
agents-cli 智能体发布与注册
google-agents-cli-publish
当用户想要“发布智能体”、“发布我的 ADK 智能体”、“向 Gemini 注册智能体”、“发布到 Gemini”(原 Gemini Enterprise),或需要了解 agents-cli publish gemini 命令的用法时,应使用本技能。当用户想要“在 Agent Registry 中管理智能体”、“列出/更新/删除已注册智能体”或“注册 MCP 服务器”时也应使用。涵盖 ADK 与 A2A 两种注册模式、编程式与交互式用法、参数(flag)说明、从部署元数据自动检测、Agent Registry 机群管理以及故障排查。属于 agents-cli 技能套件。请勿用于部署(部署请使用 google-agents-cli-deploy)。
Agents CLI 智能体评估
google-agents-cli-eval
当用户想要『运行评估』『评估我的智能体』『评估我的 ADK 智能体』『编写评估数据集』『分析评估失败』『比较评估结果』『优化智能体』,或需要有关 Gemini 平台评估方法论和质量飞轮(Quality Flywheel)的指导时,应使用本技能。涵盖评估指标、数据集模式(schema)、LLM 作为评判者(LLM-as-judge)评分和常见失败原因。适用于任何 agents-cli 项目,无论智能体用何种框架编写。不用于智能体 API 代码模式(ADK:使用 google-agents-cli-adk-code)、部署(使用 google-agents-cli-deploy)或项目脚手架(使用 google-agents-cli-scaffold)。
Agents CLI 智能体部署
google-agents-cli-deploy
当用户想要『部署智能体』『部署我的 ADK 智能体』『设置 CI/CD』『配置密钥(secrets)』『排查部署故障』,或需要有关 Agent Runtime、Cloud Run 或 GKE 部署目标,或将智能体绑定到 Agent Gateway 的指导时,应使用本技能。涵盖部署工作流、服务账号、回滚和生产基础设施。适用于 agents-cli 部署的任何框架(ADK、LangChain 等)。属于 agents-cli 技能套件。不用于智能体 API 代码模式(ADK:使用 google-agents-cli-adk-code)、评估(使用 google-agents-cli-eval)或项目脚手架(使用 google-agents-cli-scaffold)。
ADK 智能体代码编写
google-agents-cli-adk-code
当用户想要"编写智能体代码"、"使用 ADK 构建智能体"、"添加工具"、"创建回调"、"定义智能体"、"使用状态管理",且项目需要 ADK(Agent Development Kit)API 模式与代码示例时,应使用本技能。它提供智能体类型、工具定义、编排模式、回调、状态管理、图工作流 API(graph Workflow API)以及可供学习的参考配方(reference recipes)的快速参考。请勿用于脚手架搭建(请使用 google-agents-cli-scaffold)或部署(请使用 google-agents-cli-deploy)。