Skip to content

Commit 122d4de

Browse files
Enhance BigQuery Agent Analytics with new options (#1942)
* Enhance BigQuery Agent Analytics with new options Added options for OpenTelemetry correlation, custom metadata capture, and payload column projection in BigQuery Agent Analytics configuration. * Fix formatting of Interactive Demo Notebook link fix format * docs(bigquery-agent-analytics): replace version callouts with language support tags Address review feedback (koverholt) on PR #1942: the page used ad-hoc, non-conventional version callouts (per-row table tags, footnotes, version suffixes in headers, "post-vX.Y.Z" notes) that are unmaintainable and, in places, stale. - Drop the "(v2.4.0+)" / "(1.27.0+)" suffixes from config-table rows and section headers; convey minimum versions with the repo-standard language-support-tag blocks on the relevant sections instead (Trace correlation → Python v2.4.0, Automatically Created Views → Python v1.27.0, ADK 2.0 workflow events → Python v2.3.0). - Remove the "‡ Added in v2.4.0" and "† ... not in v2.2.0" view-table footnotes; the ADK 2.0 views/columns now point to the ADK 2.0 section. - Remove the stale top "Version Requirement" note (v2.2.0 is no longer the latest release; ADK 2.0 workflow support shipped in v2.3.0) and the stale ADK 2.0 section note; de-version the intro prose. - Remove the "Structured tool declarations (post-v2.4.0)" note: that shape is not in any tagged release (v2.4.0 emits tools as a list of names); it will be re-added under a language-support-tag once it ships. - Trim the Trace-correlation section so it no longer restates the option table, keeping only the cross-option constraints and the combined example.
1 parent 7458d68 commit 122d4de

1 file changed

Lines changed: 67 additions & 43 deletions

File tree

docs/integrations/bigquery-agent-analytics.md

Lines changed: 67 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,26 @@ catalog_tags: ["observability", "google"]
1111
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v1.21.0</span><span class="lst-java">Java v1.5.0</span>
1212
</div>
1313

14-
!!! important "Version Requirement"
15-
16-
Use ADK Python version 1.26.0 or higher for auto-schema-upgrade, tool
17-
provenance tracking, and HITL event tracing, and 1.27.0 or higher for
18-
automatic view creation.
19-
20-
The **ADK 2.0** multi-agent workflow features in this document — the
21-
`AGENT_TRANSFER`, `AGENT_STATE_CHECKPOINT`, `EVENT_COMPACTION`, and
22-
`TOOL_PAUSED` event types, the `attributes.adk` envelope, and the ADK 2.0
23-
views and columns — require a newer build of the plugin. As of this writing
24-
that support is present on `google/adk-python` `main` but is **not yet in a
25-
published release** (it is not in `v2.2.0`, the latest release). See [Agent
26-
workflow and pause/resume events (ADK 2.0)](#adk-2-events) for details.
27-
2814
The BigQuery Agent Analytics Plugin significantly enhances Agent Development Kit
2915
(ADK) by providing a robust solution for in-depth agent behavior analysis. Using
3016
the ADK Plugin architecture and the **BigQuery Storage Write API**, it captures
3117
and logs critical operational events directly into a Google BigQuery table,
3218
empowering you with advanced capabilities for debugging, real-time monitoring,
3319
and comprehensive offline performance evaluation.
3420

35-
Python version 1.26.0 adds **Auto Schema Upgrade** (safely add new columns to existing
36-
tables), **Tool Provenance** tracking (LOCAL, MCP, SUB_AGENT, A2A,
37-
TRANSFER_AGENT, TRANSFER_A2A), and **HITL Event Tracing** for human-in-the-loop
38-
interactions. Version 1.27.0 adds **Automatic View Creation** (generate flat,
39-
query-friendly event views).
21+
The plugin also provides **Auto Schema Upgrade** (safely add new columns to
22+
existing tables), **Tool Provenance** tracking (LOCAL, MCP, SUB_AGENT, A2A,
23+
TRANSFER_AGENT, TRANSFER_A2A), **HITL Event Tracing** for human-in-the-loop
24+
interactions, and **Automatic View Creation** (generate flat, query-friendly
25+
event views).
4026

4127
Support for **ADK 2.0** multi-agent workflows extends tracing to agent
4228
transfers, state checkpoints, event compaction, and long-running tools. It adds
4329
four new event types — `AGENT_TRANSFER`, `AGENT_STATE_CHECKPOINT`,
4430
`EVENT_COMPACTION`, and `TOOL_PAUSED` — and stamps an `attributes.adk` envelope
4531
on every row so you can reconstruct the agent execution graph and join a paused
4632
tool to the row that resumes it. See [Agent workflow and pause/resume events
47-
(ADK 2.0)](#adk-2-events) for the event details and the release that includes
48-
this support.
33+
(ADK 2.0)](#adk-2-events) for details.
4934

5035
The plugin includes three reliability and observability fixes:
5136

@@ -567,8 +552,11 @@ account) under which the agent is running needs these Google Cloud roles:
567552
| `log_session_metadata` | `bool` | `True` | Add session info to `attributes` (`session_id`, `app_name`, `user_id`, `state`). Keys prefixed `temp:` or `secret:` are [redacted](#built-in-redaction). |
568553
| `custom_tags` | `Dict[str, Any]` | `{}` | Add static tags (e.g., `{"env": "prod"}`) to every event's `attributes` |
569554
| `auto_schema_upgrade` | `bool` | `True` | Automatically add new columns to existing tables (additive only) |
570-
| `create_views` | `bool` | `True` | Create per-event-type BigQuery views (1.27.0+) |
555+
| `create_views` | `bool` | `True` | Create per-event-type BigQuery views |
571556
| `view_prefix` | `str` | `"v"` | Avoid view-name collisions when multiple plugins share a dataset (e.g., `"v_staging"`) |
557+
| `enable_otel_correlation` | `bool` | `False` | Capture the ambient OpenTelemetry span context into `attributes.otel.{span_id, trace_id}` as a best-effort Cloud Trace join key |
558+
| `custom_metadata_allowlist` | `Optional[List[str]]` | `None` | Capture selected `event.custom_metadata` keys into `attributes.custom_metadata.*` — exact keys or `"prefix*"` patterns |
559+
| `payload_column_denylist` | `Optional[List[str]]` | `None` | Project payload columns (`content`, `content_parts`, `attributes`, `latency_ms`) out of the table at write time |
572560

573561

574562
The following code sample shows how to define a configuration for the BigQuery
@@ -621,6 +609,41 @@ account) under which the agent is running needs these Google Cloud roles:
621609
)
622610
```
623611

612+
### Trace correlation, metadata capture, and column projection
613+
614+
<div class="language-support-tag">
615+
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v2.4.0</span>
616+
</div>
617+
618+
Three options control what extra context lands in `attributes` — and whether
619+
payload columns are written at all. Each is listed in the
620+
`BigQueryLoggerConfig` options table above; the notes below add the
621+
cross-option rules the flat table can't express:
622+
623+
- **`enable_otel_correlation`** — the captured span context is a best-effort
624+
Cloud Trace correlation key, not a foreign key; when disabled (the
625+
default) no `attributes.otel` is written.
626+
- **`custom_metadata_allowlist`** — leaving it unset preserves the previous
627+
behavior, where only the built-in `a2a:*` capture runs. Captured values
628+
pass the same safety pipeline as all other logged content (truncation,
629+
sensitive-key redaction, circular-reference handling).
630+
- **`payload_column_denylist`** — only `content`, `content_parts`,
631+
`attributes`, and `latency_ms` may be listed; identity and correlation
632+
columns are protected and raise `ValueError`. The projection is applied
633+
schema-first, so the table schema, the written rows, and the auto-created
634+
views stay consistent (views drop derived columns that depend on a denied
635+
column). Denying `attributes` also disables `attributes.otel` and
636+
`attributes.custom_metadata`, and combining it with a non-empty
637+
`custom_metadata_allowlist` is rejected at construction.
638+
639+
```python
640+
config = BigQueryLoggerConfig(
641+
enable_otel_correlation=True, # join key against Cloud Trace
642+
custom_metadata_allowlist=["ticket_id", "exp:*"], # capture selected custom_metadata keys
643+
# payload_column_denylist=["content_parts"], # don't persist multimodal payloads
644+
)
645+
```
646+
624647
=== "Java"
625648

626649
In Java, all configuration is managed via the `BigQueryLoggerConfig` builder.
@@ -753,9 +776,13 @@ you can optionally create the table manually using the DDL below.
753776
CLUSTER BY event_type, agent, user_id;
754777
```
755778

756-
### Automatically Created Views (1.27.0+)
779+
### Automatically Created Views
757780

758-
When `create_views=True` (the default in 1.27.0 and higher), the plugin
781+
<div class="language-support-tag">
782+
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v1.27.0</span>
783+
</div>
784+
785+
When `create_views=True` (the default), the plugin
759786
automatically generates views for each event type that unnest common JSON
760787
structures into flat, typed columns. This significantly simplifies SQL,
761788
eliminating the need to write complex `JSON_VALUE` or `JSON_QUERY` functions
@@ -798,10 +825,10 @@ columns:
798825
| --- | --- |
799826
| **`v_user_message_received`** | *(common columns only)* |
800827
| **`v_llm_request`** | `model` (STRING), `request_content` (JSON), `llm_config` (JSON), `tools` (JSON) |
801-
| **`v_llm_response`** | `response` (JSON), `usage_prompt_tokens` (INT64), `usage_completion_tokens` (INT64), `usage_total_tokens` (INT64), `usage_cached_tokens` (INT64), `total_ms` (INT64), `ttft_ms` (INT64), `model_version` (STRING), `usage_metadata` (JSON), `cache_metadata` (JSON), `context_cache_hit_rate` (FLOAT64) |
828+
| **`v_llm_response`** | `response` (JSON), `usage_prompt_tokens` (INT64), `usage_completion_tokens` (INT64), `usage_total_tokens` (INT64), `usage_cached_tokens` (INT64), `usage_thinking_tokens` (INT64), `usage_tool_use_tokens` (INT64), `total_ms` (INT64), `ttft_ms` (INT64), `model_version` (STRING), `usage_metadata` (JSON), `cache_metadata` (JSON), `context_cache_hit_rate` (FLOAT64) |
802829
| **`v_llm_error`** | `total_ms` (INT64) |
803830
| **`v_tool_starting`** | `tool_name` (STRING), `tool_args` (JSON), `tool_origin` (STRING) |
804-
| **`v_tool_completed`** | `tool_name` (STRING), `tool_result` (JSON), `tool_origin` (STRING), `total_ms` (INT64), `pause_kind` (STRING), `function_call_id` (STRING) |
831+
| **`v_tool_completed`** | `tool_name` (STRING), `tool_result` (JSON), `tool_origin` (STRING), `total_ms` (INT64), `pause_kind` (STRING), `function_call_id` (STRING) |
805832
| **`v_tool_error`** | `tool_name` (STRING), `tool_args` (JSON), `tool_origin` (STRING), `total_ms` (INT64) |
806833
| **`v_agent_starting`** | `agent_instruction` (STRING) |
807834
| **`v_agent_completed`** | `total_ms` (INT64) |
@@ -813,15 +840,15 @@ columns:
813840
| **`v_hitl_input_request`** | `tool_name` (STRING), `tool_args` (JSON) |
814841
| **`v_a2a_interaction`** | `response_content` (JSON), `a2a_task_id` (STRING), `a2a_context_id` (STRING), `a2a_request` (JSON), `a2a_response` (JSON) |
815842
| **`v_agent_response`** | `response_text` (STRING), `source_event_id` (STRING), `source_event_author` (STRING), `source_event_branch` (STRING) |
816-
| **`v_agent_transfer`** | `from_agent` (STRING), `to_agent` (STRING), `source_event_id` (STRING) |
817-
| **`v_agent_state_checkpoint`** | `agent_state` (JSON), `agent_state_type` (STRING), `end_of_agent` (BOOL), `source_event_id` (STRING) |
818-
| **`v_event_compaction`** | `start_seconds` (FLOAT64), `end_seconds` (FLOAT64), `window_start` (TIMESTAMP), `window_end` (TIMESTAMP), `compacted_content` (JSON, holding the formatted summary string) |
819-
| **`v_tool_paused`** | `tool_name` (STRING), `tool_args` (JSON), `pause_kind` (STRING), `function_call_id` (STRING) |
843+
| **`v_agent_transfer`** | `from_agent` (STRING), `to_agent` (STRING), `source_event_id` (STRING) |
844+
| **`v_agent_state_checkpoint`** | `agent_state` (JSON), `agent_state_type` (STRING), `end_of_agent` (BOOL), `source_event_id` (STRING) |
845+
| **`v_event_compaction`** | `start_seconds` (FLOAT64), `end_seconds` (FLOAT64), `window_start` (TIMESTAMP), `window_end` (TIMESTAMP), `compacted_content` (JSON, holding the formatted summary string) |
846+
| **`v_tool_paused`** | `tool_name` (STRING), `tool_args` (JSON), `pause_kind` (STRING), `function_call_id` (STRING) |
820847

821-
† Part of the [ADK 2.0 workflow event support](#adk-2-events): created only by
822-
builds that include it (not in `v2.2.0`). On a 1.27.0+ release without that
823-
support, these four views are not created and `v_tool_completed` does not have
824-
the `pause_kind` / `function_call_id` columns.
848+
The four workflow views (`v_agent_transfer`, `v_agent_state_checkpoint`,
849+
`v_event_compaction`, `v_tool_paused`) and the `pause_kind` / `function_call_id`
850+
columns on `v_tool_completed` come with the [ADK 2.0 workflow event
851+
support](#adk-2-events).
825852

826853
## Event types and payloads {#event-types}
827854

@@ -870,6 +897,9 @@ instructions.
870897
}
871898
```
872899

900+
The automatically created `v_llm_request` view exposes the `tools` attribute as
901+
its `tools` (JSON) column.
902+
873903
**2. LLM_RESPONSE**
874904

875905
Captures the model's output and token usage statistics.
@@ -1110,15 +1140,9 @@ Logged when an A2A remote agent call completes.
11101140

11111141
### Agent workflow and pause/resume events (ADK 2.0) {#adk-2-events}
11121142

1113-
!!! important "Version Requirement"
1114-
1115-
The event types in this section require a build of the plugin that includes
1116-
the ADK 2.0 workflow event support. As of this writing that support is
1117-
present on `google/adk-python` `main` but is **not yet in a published
1118-
release** (it is not in `v2.2.0`, the latest release). On a build without it
1119-
the plugin does not emit these events and the `attributes.adk` envelope is
1120-
absent. This note will name the first release that includes the support once
1121-
it is tagged.
1143+
<div class="language-support-tag">
1144+
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v2.3.0</span>
1145+
</div>
11221146

11231147
ADK 2.0 introduced multi-agent workflows (agents that transfer control,
11241148
checkpoint their state, and compact long histories) and long-running tools that

0 commit comments

Comments
 (0)