You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
a2ce34a0b9
This commit refactors the `BigQueryAgentAnalyticsPlugin` to leverage the modern BigQuery Storage Write API, replacing the previous implementation that used the legacy `insert_rows_json` method (based on `tabledata.insertAll`). **Key Changes:** * **Switched to Storage Write API:** Event logs are now ingested using the `BigQueryWriteClient` from the `google-cloud-bigquery-storage` library. * **Utilizes Default Stream:** We are using the `_default` stream for sending data, which is an efficient method for streaming in data without needing to manage stream lifecycles. This is ideal for continuous event logging. * **Apache Arrow Format:** Log entries are converted to the Apache Arrow format using `pyarrow` before being sent. The BigQuery table schema is dynamically converted to an Arrow schema. This binary format is more efficient than JSON. * **Updated Initialization:** The plugin now initializes both the standard `bigquery.Client` (for table management) and the `BigQueryWriteClient`. * **Test Updates:** Unit tests in `test_bigquery_logging_plugin.py` have been comprehensively updated to mock the new `BigQueryWriteClient`, `bq_schema_utils`, and `pyarrow` components. Tests now verify calls to `append_rows` and the data structure passed to create the Arrow RecordBatch. **Benefits of this change:** * **Improved Performance:** The Storage Write API is designed for high-throughput streaming and offers better performance compared to the legacy API. * **Reduced Cost:** Ingesting data via the Storage Write API is generally more cost-effective. * **Enhanced Reliability:** The Storage Write API provides more robust streaming capabilities. * **Modernization:** Aligns the plugin with the recommended best practices for BigQuery data ingestion. This change enhances the efficiency and scalability of the BigQuery logging plugin. PiperOrigin-RevId: 828655496