Skip to content

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

Closed

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

Activity

  1. added
    bq[Component] This issue is related to Big Query integration
    on Jan 20, 2026
  2. added theissue type on Jan 20, 2026
  3. caohy1988 commented on Feb 9, 2026

    @caohy1988

    Recommended Solution: Use custom_tags

    Technically, the existing custom_tags configuration already solves the core problem: injecting static metadata into every analytics event.

    Instead of waiting for a new default_attributes feature, you can configure your BigQueryLoggerConfig right now like this:

    config = BigQueryLoggerConfig(
        # ... other config ...
        custom_tags={
            "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"),
        }
    )

    This approach avoids waiting for a new release and keeps your deployment metadata cleanly separated from other dynamic event attributes.

    Querying Metadata

    The only user-facing difference between custom_tags and the proposed default_attributes feature is the JSON path in BigQuery. Your metadata will be nested under a custom_tags key within the attributes JSON column (rather than being at the root).

    You can query it easily using JSON functions:

    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.

  4. klateefa commented on Feb 11, 2026

    @klateefa

    @andrewrfitz Thank you for informing us. Please be assured that the request is under review, and we will keep you informed of any next steps. We appreciate your patience.
    Thanks

  5. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bq[Component] This issue is related to Big Query integrationneeds review[Status] The PR/issue is awaiting review from the maintainer

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions