Cloud Trace Querying
GoogleOfficialPublished by Google
- Skill
- Tool integration
- Cloud and DevOps
- Apache-2.0
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The cloud-trace-querying skill enables agents to interact directly with Google Cloud Trace to investigate performance issues. It provides structured workflows to search for traces based on latency or error status, inspect trace hierarchies, and retrieve correlated application logs from Cloud Logging. The skill is designed for diagnosing latency regressions and service bottlenecks within Google Cloud environments by executing specific diagnostic scripts and formatting the results for analysis.
What it does
- Searches for traces using latency thresholds and error filters.
- Fetches full trace hierarchies to visualize span relationships.
- Retrieves application logs correlated with specific trace IDs.
- Inspects individual span attributes and metadata.
- Generates direct Cloud Console deep links for further manual inspection.
- Formats trace data into ASCII timelines or JSON graphs.
When to use it
- When investigating slow requests or latency regressions in GCP services.
- When analyzing trace hierarchies to identify bottlenecks.
- When correlating error logs with specific distributed trace events.
- When troubleshooting service crashes or unexpected error statuses.
Advantages
- Provides standardized diagnostic workflows for GCP observability.
- Enables direct correlation between distributed traces and application logs.
- Supports flexible filtering by latency and error status.
- Automates the generation of deep links for rapid transition to the Cloud Console.
Usage examples
- “Find all traces for /v1/booking/book that took longer than 1.5 seconds.”
- The agent executes the search script with the specified filter and returns a list of matching trace IDs and their durations.
- “Show me the logs related to trace ID 12345.”
- The agent fetches and displays application log entries correlated with the provided trace ID to help identify the root cause of an error.
- “Generate a link to view trace 12345 in the Google Cloud Console.”
- The agent provides a direct URL that opens the specific trace in the Cloud Trace Explorer.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/google/cloud-trace-querying/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip cloud-trace-querying.zip -d .agents/skills
Documentation by Google
Cloud Trace Querying Skill (cloud-trace-querying)
This skill equips the agent to interact with Cloud Trace by providing standard query patterns, diagnostic workflows for latency and errors, and tools to fetch and inspect trace hierarchies.
[!IMPORTANT] AUTONOMOUS TOOL EXECUTION MANDATE: You MUST execute the tool scripts directly in bash to query telemetry. Do NOT just describe query strings or write Python scripts. Run the provided bash tools directly and report the exact results.
Attribution
MUST READ: Before executing any gcloud, REST API, or MCP command, you
MUST read Usage Attribution. For commands executed
directly in the terminal (never in generated scripts, Terraform, or user code),
prefix gcloud with
CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-trace-querying)"
and append agent-skills/1.0 (skill:cloud-trace-querying) to User-Agent headers.
Prerequisites & Setup
Google Cloud SDK: Verify
gcloudis installed (Installation Guide).Authentication: Authenticate CLI and application default credentials:
gcloud auth login && gcloud auth application-default loginProject & Billing: Identify the target
<PROJECT_ID>(from the user's prompt or viabash scripts/get_trace_project/run.sh), ensure an active billing account is attached, and configure the project if not already set:gcloud config set project <PROJECT_ID>API Enablement: Verify Cloud Trace and Cloud Logging APIs are enabled:
gcloud services enable cloudtrace.googleapis.com logging.googleapis.com
Quickstart Workflows
1. Identify Google Cloud Project ID
If the user specified a Google Cloud project ID in their prompt, use it.
If they did not, ALWAYS determine the Google Cloud project ID by running:
bash scripts/get_trace_project/run.sh2. Search Traces (Latency & Errors)
To find traces matching specific criteria, such as a root span of /v1/booking/book with a duration of at least 1.5s:
bash scripts/search_traces/run.sh --filter 'root:/v1/booking/book latency:1.5s' --projects '<PROJECT_ID>'Note: --filter is required. To list traces without specific filtering, pass --filter '' or --filter 'root:'.
Filter syntax: The Cloud Trace API uses latency:<duration> (such as latency:1.5s for duration >= 1.5s), which corresponds to "Span duration" in Trace Explorer.
The script outputs JSON where each cluster's examples array contains sample trace objects with trace_id, duration_seconds, span count, and error status.
3. Fetch Entire Trace Hierarchy
To view all spans and status codes/labels within a trace:
bash scripts/fetch_entire_trace/run.sh --trace-id '<TRACE_ID>' --project '<PROJECT_ID>'4. Fetch Correlated Application Logs
To retrieve application log entries correlated with a trace ID:
bash scripts/fetch_related_logs/run.sh --trace-id '<TRACE_ID>' --trace-projects '<PROJECT_ID>'Application log entries are useful when inspecting stack traces, exception messages, and log events emitted during span execution. When diagnosing errors or service crashes, inspect the returned log entries for severity: "ERROR" to confirm root causes or uncover unhandled exceptions.
Note: fetch_related_logs queries the default log scope (_Default), searching across configured log views in the target project. An empty response can occur if: (1) no log entries match the criteria, (2) the caller lacks IAM permissions to view the matching entries, or (3) matching entries reside in log views outside the searched log scope.
5. Fetch Specific Trace Span
To inspect attributes and metadata of a single span within a trace:
bash scripts/fetch_trace_span/run.sh --trace-id '<TRACE_ID>' --span-id '<SPAN_ID>' --project '<PROJECT_ID>'6. Generate Cloud Console Deep Links
To generate direct Cloud Console URLs for browser inspection of traces or correlated logs:
bash scripts/generate_links/run.sh --trace-id '<TRACE_ID>' --project '<PROJECT_ID>' [--span-id '<SPAN_ID>']7. Format Output
Terminal / CLI: Render span trees as indented ASCII timelines using
|--.UI Presentation: Render as A2UI JSON graph structures when requested for UI.
8. Upstream Service Error Handling
If the Cloud Trace API or Cloud Logging API returns an upstream HTTP service error (such as 500 Internal Server Error, 503 Service Unavailable, or GoogleAPICallError), report the upstream service outage directly to the user. Do not attempt to inspect virtual environments, modify internal scripts, or debug local libraries.
Reference Documentation
Master Index: Reference Documentation Index
Operational Workflows
Query Syntax & Tools
Filter Syntax (
root:,latency:,+span:,error:true)
Semantic Conventions
Concepts & Architecture
Templates & Assets
Official Documentation Links
Files
- ATTRIBUTION.mdAdded by AutoGineer858 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md7.2 KiB
- assets/formatting/a2ui/single_span/display.a2ui.json1.1 KiB
- assets/formatting/a2ui/trace_chart/display.a2ui.json1.1 KiB
- assets/formatting/a2ui/trace_flow/display.a2ui.json767 B
- assets/formatting/a2ui/traces_heat_map/display.a2ui.json1.8 KiB
- assets/formatting/ascii/single_span/display.txt377 B
- assets/formatting/ascii/trace_chart/display.txt517 B
- assets/formatting/ascii/trace_flow/display.txt430 B
- assets/formatting/ascii/traces_heat_map/display.txt887 B
- assets/queries/billing_errors/SCENARIO.md1.4 KiB
- assets/queries/billing_errors/query.txt73 B
- assets/queries/checkout_latency/SCENARIO.md416 B
- assets/queries/checkout_latency/query.txt47 B
- assets/queries/customer_spans/SCENARIO.md307 B
- assets/queries/customer_spans/query.txt24 B
- assets/queries/prod_outliers/SCENARIO.md979 B
- assets/queries/prod_outliers/query.txt51 B
- assets/queries/slow_db/SCENARIO.md440 B
- assets/queries/slow_db/query.txt35 B
- references/api-limits.md1.6 KiB
- references/attribution.md1.9 KiB
- references/concepts-span.md869 B
- references/concepts-trace.md1.3 KiB
- references/console-deep-links.md1.1 KiB
- references/conventions-gcp-legacy.md3.4 KiB
- references/conventions-gcp.md2.7 KiB
- references/conventions-otel-genai.md6.9 KiB
- references/conventions-otel-grpc.md2.4 KiB
- references/conventions-otel-http.md1.9 KiB
- references/conventions-otel.md4.2 KiB
- references/conventions.md2.5 KiB
- references/correlated-logs.md2.5 KiB
- references/decision-tree.md2.1 KiB
- references/filter-syntax.md4.0 KiB
- references/index.md2.7 KiB
- references/knowledge-overview.md3.2 KiB
- references/logs-trace-correlation.md1.7 KiB
- references/observability-scopes.md3.0 KiB
- references/querying-mcp.md2.0 KiB
- references/querying-observability-analytics.md4.9 KiB
- references/troubleshoot-latency.md2.1 KiB
- references/workflows-overview.md881 B
- scripts/fetch_entire_trace/run.shScript231 B
- scripts/fetch_entire_trace/src/main.pyScript1.8 KiB
- scripts/fetch_entire_trace/test.shScript279 B
- scripts/fetch_entire_trace/tests/main_test.pyScript3.9 KiB
- scripts/fetch_related_logs/run.shScript231 B
- scripts/fetch_related_logs/src/log_fetcher.pyScript7.4 KiB
- scripts/fetch_related_logs/src/main.pyScript2.4 KiB
- scripts/fetch_related_logs/src/observability_scopes.pyScript3.0 KiB
- scripts/fetch_related_logs/src/timestamp_utils.pyScript577 B
- scripts/fetch_related_logs/test.shScript422 B
- scripts/fetch_related_logs/tests/main_test.pyScript10.6 KiB
- scripts/fetch_related_logs/tests/timestamp_utils_test.pyScript1.1 KiB
- scripts/fetch_trace_span/run.shScript231 B
- scripts/fetch_trace_span/src/main.pyScript2.6 KiB
- scripts/fetch_trace_span/test.shScript279 B
- scripts/fetch_trace_span/tests/main_test.pyScript5.1 KiB
- scripts/generate_links/run.shScript138 B
- scripts/generate_links/src/main.pyScript1.7 KiB
- scripts/generate_links/test.shScript279 B
- scripts/generate_links/tests/main_test.pyScript2.7 KiB
- scripts/get_trace_project/run.shScript231 B
- scripts/get_trace_project/src/main.pyScript402 B
- scripts/get_trace_project/src/project_resolver.pyScript2.0 KiB
- scripts/get_trace_project/test.shScript279 B
- scripts/get_trace_project/tests/integration_test.pyScript2.7 KiB
- scripts/get_trace_project/tests/project_resolver_test.pyScript2.8 KiB
- scripts/requirements.txt92 B
- scripts/run_python_with_deps/run.shScript2.0 KiB
- scripts/run_python_with_deps/src/cleanup_env.pyScript2.1 KiB
- scripts/run_python_with_deps/src/lock_manager.pyScript2.5 KiB
- scripts/run_python_with_deps/src/manage_venv.pyScript1.7 KiB
- scripts/run_python_with_deps/src/path_resolver.pyScript3.4 KiB
- scripts/run_python_with_deps/src/venv_cleaner.pyScript800 B
- scripts/run_python_with_deps/src/venv_executor.pyScript1.2 KiB
- scripts/run_python_with_deps/src/venv_setup.pyScript2.1 KiB
- scripts/run_python_with_deps/test.shScript364 B
- scripts/run_python_with_deps/tests/cleanup_env_test.pyScript2.5 KiB
- scripts/run_python_with_deps/tests/lock_manager_test.pyScript2.0 KiB
- scripts/run_python_with_deps/tests/path_resolver_test.pyScript5.4 KiB
- scripts/run_python_with_deps/tests/venv_setup_test.pyScript1.8 KiB
- scripts/search_traces/run.shScript231 B
- scripts/search_traces/src/main.pyScript2.1 KiB
- scripts/search_traces/src/timestamp_utils.pyScript1.5 KiB
- scripts/search_traces/src/trace_searcher.pyScript16.0 KiB
- scripts/search_traces/test.shScript279 B
- scripts/search_traces/tests/main_test.pyScript2.7 KiB
- scripts/search_traces/tests/timestamp_utils_test.pyScript1.7 KiB
- scripts/search_traces/tests/trace_searcher_test.pyScript17.4 KiB
scripts/run_python_with_deps/src/venv_setup.py
"""Virtual environment initialization and package installation manager.
Handles directory setup, python virtual environment initialization, and
package installations from requirements configuration.
"""
import pathlib
import subprocess
import sys
import venv
def create_and_upgrade_pip(venv_dir: pathlib.Path, pip_path: pathlib.Path):
"""Creates the virtualenv directory and upgrades pip inside it.
Args:
venv_dir: The target path where the virtualenv should be created.
pip_path: The expected absolute path to the pip executable.
"""
venv_dir.mkdir(parents=True, exist_ok=True)
venv.create(venv_dir, system_site_packages=True, with_pip=True)
upgrade_args = [
str(pip_path),
"install",
"--timeout",
"3",
"--retries",
"0",
"--quiet",
"--upgrade",
"pip",
]
subprocess.run(upgrade_args, capture_output=True, check=False)
def install_requirements(pip_path: pathlib.Path, req_file: pathlib.Path):
"""Installs dependencies from the requirements file via pip.
Args:
pip_path: The absolute path to the pip executable.
req_file: The path to the requirements.txt file to install.
"""
install_args = [
str(pip_path),
"install",
"--timeout",
"3",
"--retries",
"0",
"--quiet",
"-r",
str(req_file),
]
res = subprocess.run(install_args, check=False)
if res.returncode != 0:
print(
"Warning: Failed to install dependencies. Proceeding anyway...",
file=sys.stderr,
)
def setup_venv_if_missing(venv_dir: pathlib.Path, req_file: pathlib.Path):
"""Initializes virtual environment and dependencies if not already present.
Args:
venv_dir: The target path where the virtualenv should exist.
req_file: The path to requirements.txt.
"""
if venv_dir.exists():
return
print(f"Creating virtual environment in {venv_dir}...", file=sys.stderr)
pip_path = venv_dir / "bin" / "pip"
create_and_upgrade_pip(venv_dir, pip_path)
print("Installing dependencies from requirements.txt...", file=sys.stderr)
install_requirements(pip_path, req_file)
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Python
Security
What our scanner noticed· Low risk
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/cloud-trace-querying · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download cloud-trace-querying.zip