-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(bigquery): add default_attributes config to BigQueryAgentAnalyticsPlugin #4207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat(bigquery): add default_attributes config to BigQueryAgentAnalyticsPlugin #4207
Conversation
…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
)
```
|
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.
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 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.
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.
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.