⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

feat: Add default_attributes config to BigQueryAgentAnalyticsPlugin for deployment metadata #4212

@andrewrfitz

Description

@andrewrfitz

Problem Statement

When deploying ADK-based services in production environments, there's no straightforward way to include deployment metadata (service version, environment, commit SHA, deployment ID, etc.) in BigQuery analytics events. This metadata is essential for:

  1. Debugging production issues - Correlating agent behavior with specific deployments
  2. A/B testing and rollouts - Comparing metrics across different service versions
  3. Environment filtering - Separating production vs staging vs development analytics
  4. Audit and compliance - Tracking which version of the service generated specific events

Current Workaround

Currently, users must manually inject these attributes into every event, which is:

  • Error-prone (easy to forget)
  • Repetitive (same metadata on every call)
  • Not centralized (scattered across the codebase)

Proposed Solution

Add a default_attributes configuration option to BigQueryLoggerConfig that automatically merges static key-value pairs into every logged event's attributes field.

Example Usage

config = BigQueryLoggerConfig(
    default_attributes={
        "service_version": os.getenv("SERVICE_VERSION", "unknown"),
        "environment": os.getenv("ENVIRONMENT", "development"),
        "commit_sha": os.getenv("COMMIT_SHA", "unknown"),
        "deployment_id": os.getenv("DEPLOYMENT_ID"),
    }
)

plugin = BigQueryAgentAnalyticsPlugin(
    project_id="my-project",
    dataset_id="adk_analytics",
    config=config,
)

Behavior

  • Default attributes are merged with event-specific attributes
  • Event-specific attributes take precedence on key conflicts
  • Fully backward compatible (default_attributes defaults to None)

Use Case

We're building an AI concierge service using ADK and need to track which deployment version generated each analytics event. This allows us to:

  • Query events by environment: WHERE JSON_VALUE(attributes, '$.environment') = 'production'
  • Debug specific commits: WHERE JSON_VALUE(attributes, '$.commit_sha') = 'abc123'
  • Compare version performance: GROUP BY JSON_VALUE(attributes, '$.service_version')

Implementation

PR: #4207

Metadata

Metadata

Assignees

No one assigned

    Labels

    bq[Component] This issue is related to Big Query integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions