Skip to content

Conversation

@caohy1988
Copy link

Summary

  • Comprehensive demo comparing BigQuery Agent Analytics Plugin vs Cloud Logging/Trace approaches for ADK agent telemetry
  • Includes working code with real test results from project test-project-0728-467323
  • Demonstrates AI-powered analytics with BigQuery + Gemini

Key Findings

Approach Setup Effort Data Coverage Real-time AI Analytics
BigQuery Plugin 10 lines Python 100% ✅ Yes ✅ Full
Cloud Trace → BQ 500+ lines code ~80% ❌ Manual ETL ✅ Full
Cloud Logging → BQ 150 lines shell ~20% ⚠️ Delayed Limited

Files Added (14 files, ~3,800 lines)

Agent & Runners:

  • agent.py - Demo agent with 4 tools (weather, trip cost, flaky API, sentiment)
  • run_with_bq_analytics.py - BigQuery plugin runner
  • run_cloud_logging_demo.py - Cloud Trace/Logging runner

BigQuery Plugin Queries:

  • bq_analysis_queries.sql - 30+ SQL queries for token usage, tool analytics, latency
  • bq_ai_powered_analytics.sql - AI-powered queries (LLM-as-Judge, jailbreak detection, sentiment)

Cloud Trace Export Pipeline:

  • setup_trace_to_bigquery.sh - Setup script for trace export
  • export_traces_to_bigquery.py - ETL script to export traces to BigQuery
  • trace_export_queries.sql - SQL queries for exported trace data

Cloud Logging Export:

  • setup_cloud_logging_export.sh - Cloud Logging to BQ export setup
  • cloud_logging_export_queries.sql - Queries for exported logs

Documentation:

  • README.md - Comprehensive comparison one-pager with real results

Test plan

  • BigQuery Analytics demo runs successfully with real data
  • Cloud Trace demo exports spans to BigQuery
  • SQL queries return expected results
  • Token usage, tool analytics, and latency metrics verified

🤖 Generated with Claude Code

This demo compares approaches for logging and analyzing ADK agent telemetry:

1. BigQuery Agent Analytics Plugin - purpose-built for agent analytics
2. Cloud Trace via OTel - standard observability with manual BigQuery export
3. Cloud Logging Export - limited data capture

Key findings:
- BigQuery Plugin: 10 lines setup, real-time, 100% data coverage
- Cloud Trace → BQ: 500+ lines ETL code, manual export, ~80% coverage
- Cloud Logging → BQ: 150 lines setup, ~20% data coverage

Includes:
- Demo agent with 4 tools (weather, trip cost, flaky API, sentiment)
- SQL queries for token usage, tool analytics, latency analysis
- AI-powered analytics with Gemini (LLM-as-Judge, jailbreak detection)
- Complete Cloud Trace to BigQuery export pipeline
- Comprehensive comparison documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@google-cla
Copy link

google-cla bot commented Jan 6, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @caohy1988, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request delivers a comprehensive demonstration and comparison of different strategies for collecting and analyzing telemetry data from ADK agents. It aims to highlight the superior capabilities of the BigQuery Agent Analytics Plugin, particularly its seamless integration with AI for advanced insights and its efficiency in data capture and setup. The demo meticulously contrasts this plugin with the more conventional Cloud Logging and Cloud Trace methods, illustrating their limitations in terms of data completeness, real-time processing, and the significant manual effort required to achieve comparable analytical depth.

Highlights

  • Comprehensive Telemetry Comparison: This pull request introduces a detailed demo comparing the BigQuery Agent Analytics Plugin against various Cloud Logging and Cloud Trace approaches for collecting and analyzing ADK agent telemetry.
  • AI-Powered Analytics with BigQuery: The demo prominently features BigQuery's integration with Vertex AI Gemini, enabling advanced AI-powered analytics such as LLM-as-Judge evaluation, jailbreak detection, tool failure root cause analysis, sentiment analysis, and memory extraction, which are not feasible with Cloud Logging.
  • Reduced Setup Effort and Data Completeness: It demonstrates that the BigQuery plugin offers significantly easier setup (around 10 lines of Python) and captures 100% of structured telemetry data in near real-time, contrasting sharply with the extensive setup (150-500+ lines of code/scripts) and limited data coverage (20-80%) of Cloud Logging/Trace export pipelines.
  • Architectural Clarity on ADK Telemetry: The PR clarifies a critical architectural point: ADK agents emit telemetry as OpenTelemetry spans (traces), not traditional log records. This distinction explains why Cloud Logging exporters capture limited data and why manual ETL is required to get meaningful analytics from Cloud Trace.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the tracing [Component] This issue is related to OpenTelemetry tracing label Jan 6, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Jan 6, 2026

Response from ADK Triaging Agent

Hello @caohy1988, thank you for your contribution!

This looks like a great new feature. According to our contribution guidelines, all new features should have an associated GitHub issue. Could you please create one for this pull request?

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive demonstration comparing BigQuery and Cloud Logging for ADK agent telemetry. The addition is substantial, providing runnable code, setup scripts, and detailed documentation. The overall structure and implementation are well-executed for a demonstration. My review has identified a few areas for improvement: an incorrect dependency noted in a script comment, a data corruption bug within the trace export script, and an inconsistent query in one of the execution scripts. I have included specific suggestions to address these points. With these changes, this will be an excellent resource for developers.

Comment on lines +136 to +137
input_tokens = int(labels.get("gen_ai.usage.input_tokens", 0)) or None
output_tokens = int(labels.get("gen_ai.usage.output_tokens", 0)) or None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There's a bug in the way token counts are parsed. The expression int(labels.get(..., 0)) or None incorrectly converts a token count of 0 to None, which leads to data loss. This occurs because int(0) evaluates to 0, and 0 or None results in None. The logic should be updated to correctly handle cases where the token count is zero.

Suggested change
input_tokens = int(labels.get("gen_ai.usage.input_tokens", 0)) or None
output_tokens = int(labels.get("gen_ai.usage.output_tokens", 0)) or None
input_tokens_str = labels.get("gen_ai.usage.input_tokens")
input_tokens = int(input_tokens_str) if input_tokens_str is not None else None
output_tokens_str = labels.get("gen_ai.usage.output_tokens")
output_tokens = int(output_tokens_str) if output_tokens_str is not None else None

Comment on lines +187 to +189
JSON_EXTRACT_SCALAR(content, '$.usage.total_token_count') as tokens,
JSON_EXTRACT_SCALAR(content, '$.usage.prompt_token_count') as prompt_tokens,
JSON_EXTRACT_SCALAR(content, '$.usage.candidates_token_count') as response_tokens
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The JSON paths for token counts in this query (total_token_count, prompt_token_count, candidates_token_count) are inconsistent with the data schema documented in README.md and the queries in bq_analysis_queries.sql. Other files in this demo use total, prompt, and completion. To ensure this example query functions correctly with the demo's data, please update the JSON paths for consistency.

Suggested change
JSON_EXTRACT_SCALAR(content, '$.usage.total_token_count') as tokens,
JSON_EXTRACT_SCALAR(content, '$.usage.prompt_token_count') as prompt_tokens,
JSON_EXTRACT_SCALAR(content, '$.usage.candidates_token_count') as response_tokens
JSON_EXTRACT_SCALAR(content, '$.usage.total') as tokens,
JSON_EXTRACT_SCALAR(content, '$.usage.prompt') as prompt_tokens,
JSON_EXTRACT_SCALAR(content, '$.usage.completion') as response_tokens

Comment on lines +20 to +22
# pip install opentelemetry-exporter-gcp-logging \
# opentelemetry-exporter-gcp-monitoring \
# opentelemetry-exporter-otlp-proto-grpc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The comment suggests opentelemetry-exporter-otlp-proto-grpc as a prerequisite. However, ADK's OTLP exporters utilize the HTTP protocol, making opentelemetry-exporter-otlp-proto-http the correct dependency. Please update the comment to guide users to install the correct package.

Suggested change
# pip install opentelemetry-exporter-gcp-logging \
# opentelemetry-exporter-gcp-monitoring \
# opentelemetry-exporter-otlp-proto-grpc
# pip install opentelemetry-exporter-gcp-logging \
# opentelemetry-exporter-gcp-monitoring \
# opentelemetry-exporter-otlp-proto-http

caohy1988 and others added 2 commits January 6, 2026 03:22
Address peer review feedback to make the document more resilient:

1. Change "IMPOSSIBLE" to "High Friction / Non-Native" framing
   - More accurate engineering trade-off language
   - Acknowledges Log Analytics can technically access AI

2. Add "Schema Stability" as key advantage
   - BigQuery Plugin provides agent-aware, documented contract
   - OTel attribute names may change without notice

3. Acknowledge Cloud Logging Log Analytics feature
   - Note it doesn't solve the "missing data" problem
   - Tokens, full responses still not captured

4. Clarify "Real-Time" nuances
   - "Operational real-time" (Live Tail) vs "Analytical real-time"
   - Cloud Trace wins for "debug this call now"
   - BigQuery wins for "what's our trend?"

5. Add OTel attribute size limits section
   - 128KB span limit affects large payloads
   - Multi-modal content won't fit
   - BigQuery Plugin handles via GCS offloading

6. Give Cloud Trace credit for visualization
   - Gantt charts are unmatched for latency debugging
   - Acknowledge "Trace ID: Cloud Trace wins"

7. Update conclusion to be balanced
   - "Use Both in Production" recommendation
   - Complementary tools, not competing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add a concise executive summary at the beginning that:
- Positions BigQuery Plugin as "Intelligence Layer"
- Positions Cloud Trace/Logging as "Observation Layer"
- Provides quick decision table for common questions
- Emphasizes complementary nature of both approaches
- Highlights schema stability as key differentiator

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ryanaiagent ryanaiagent self-assigned this Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tracing [Component] This issue is related to OpenTelemetry tracing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants