feat(bigquery): add default_attributes config to BigQueryAgentAnalyticsPlugin#4207
feat(bigquery): add default_attributes config to BigQueryAgentAnalyticsPlugin#4207andrewrfitz wants to merge 2 commits intogoogle:mainfrom
Conversation
|
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. |
Summary of ChangesHello @andrewrfitz, 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 enhances the BigQuery analytics plugin by providing a mechanism to automatically enrich all logged events with predefined, static metadata. This capability simplifies the process of adding consistent contextual information, such as deployment details, to analytics data, which is invaluable for subsequent filtering, analysis, and debugging within BigQuery without requiring manual inclusion in every event. Highlights
🧠 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 AssistThe 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
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 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
|
|
Response from ADK Triaging Agent Hello @andrewrfitz, thank you for your contribution! Before we can merge this PR, could you please:
This will help us to track the work and review your PR more efficiently. Thanks! |
There was a problem hiding this comment.
Code Review
This pull request introduces a default_attributes configuration option to the BigQueryAgentAnalyticsPlugin, allowing for the injection of static key-value pairs into every logged event. This is a valuable feature for enriching analytics data with deployment metadata. The implementation correctly merges default and event-specific attributes, prioritizing the latter in case of conflicts. The changes are well-documented, and the accompanying unit tests are comprehensive, covering all key aspects of the new functionality including attribute inclusion, overriding, and backward compatibility. The code quality is high, and I have no concerns with the proposed changes.
2ceb2cc to
99be03e
Compare
|
@ryanaiagent I've followed the steps for CLA as a 'Corporate signer', I'm in the google group and signed the CLA, but it's still failing the git action. Can you provide an guidance here? |
|
Hi @andrewrfitz , try https://cla.developers.google.com/ . |
99be03e Author: @andrewrfitz <and******tz@bilt.com> I've signed the CLA, and this email is in the google group associated, but the check is still failing. Not sure if there's anything else I can try? |
|
Hi @andrewrfitz , maybe try the following the steps mentioned in the link below for googlers and TVC. |
99be03e to
34fea3e
Compare
…csPlugin
Add a new `default_attributes` configuration option to BigQueryLoggerConfig
that allows users to inject static key-value pairs into every logged event's
attributes field. This is useful for adding deployment metadata like service
version, environment, or commit SHA to all analytics events.
Features:
- New `default_attributes: Optional[dict[str, Any]]` config field
- Default attributes are merged into every event's attributes
- Event-specific attributes override defaults when there are conflicts
- Fully backward compatible (None by default)
Example usage:
```python
config = BigQueryLoggerConfig(
default_attributes={
"service_version": "1.2.3",
"environment": "production",
}
)
plugin = BigQueryAgentAnalyticsPlugin(
project_id, dataset_id, config=config
)
```
34fea3e to
9e2355f
Compare
I've tried everything, still not working :/ My public email is in our corporate CLA, its the same one attached to my commit |
|
@ryanaiagent finally got it working! ready for review now, thank you for your help 🙏 |
|
Hi @Jacksunwei , can you please review this. |
2fa9b88 to
f4acc63
Compare
Resolves merge conflicts by keeping both features: - default_attributes config option (this branch) - log_session_metadata and custom_tags config options (main)
f4acc63 to
a22ce47
Compare
Recommended Solution: Use
|
| Feature | Query Syntax |
|---|---|
default_attributes (Proposed) |
WHERE JSON_VALUE(attributes, '$.environment') = 'production' |
custom_tags (Existing) |
WHERE JSON_VALUE(attributes, '$.custom_tags.environment') = 'production' |
Example queries:
-- Query events by environment
SELECT *
FROM `your_project.your_dataset.agent_events_v2`
WHERE JSON_VALUE(attributes, '$.custom_tags.environment') = 'production'
-- Debug specific commits
SELECT *
FROM `your_project.your_dataset.agent_events_v2`
WHERE JSON_VALUE(attributes, '$.custom_tags.commit_sha') = 'abc123';Recommendation
Unless you have a strict requirement for "root-level" attributes (e.g., for compatibility with existing queries or downstream pipelines that expect a flat schema), we recommend using custom_tags.
Using custom_tags keeps the API surface smaller and cleaner. It also neatly namespaces "deployment/environment" metadata away from "runtime/event" metadata, which is arguably a better practice anyway.
We suggest closing this feature request as "Working as Intended" by leveraging the existing custom_tags functionality.
Thanks for the detailed response @caohy1988! You're right that custom_tags covers the static deployment metadata use case I described in this PR. However, my broader goal is actually per-session dynamic metadata in BigQuery events, not just static deployment tags. For example, attaching session-specific context to every event row so I can filter/debug in BigQuery at the session level. custom_tags can't solve this since it's set once at plugin construction time and stamped identically on every event across all sessions. Thoughts on this? |
Summary
This PR adds a new
default_attributesconfiguration option toBigQueryLoggerConfigthat allows users to inject static key-value pairs into every logged event'sattributesfield.Use case: When deploying ADK-based services, it's useful to include deployment metadata (service version, environment, commit SHA, etc.) in analytics events for filtering and debugging in BigQuery.
Closes #4212
Changes
default_attributes: Optional[dict[str, Any]] = NonetoBigQueryLoggerConfig_log_event()to merge default attributes with event-specific attributesNone)Example Usage
All events logged by this plugin will now include these attributes in the
attributesJSON column.Testing Plan
Unit Tests
Added 3 new unit tests:
test_default_attributes_included_in_events- verifies default attributes appear in logged eventstest_default_attributes_overridden_by_event_attributes- verifies event-specific attributes take precedencetest_default_attributes_none_does_not_affect_events- verifies backward compatibilityTest Results
All existing tests continue to pass.