Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Inject invocation_id into user agent string
time: 2025-09-04T15:33:41.438521+12:00
custom:
Author: jeremyyeo
Issue: "1280"
5 changes: 4 additions & 1 deletion dbt-bigquery/src/dbt/adapters/bigquery/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from google.cloud.storage import Client as StorageClient
from google.cloud.storage.retry import DEFAULT_RETRY as GCS_DEFAULT_RETRY
from google.oauth2.credentials import Credentials as GoogleCredentials
from dbt_common.invocation import get_invocation_id

from dbt.adapters.events.logging import AdapterLogger

Expand Down Expand Up @@ -64,7 +65,9 @@ def _create_bigquery_client(credentials: BigQueryCredentials) -> BigQueryClient:
credentials.execution_project,
create_google_credentials(credentials),
location=getattr(credentials, "location", None),
client_info=ClientInfo(user_agent=f"dbt-bigquery-{dbt_version.version}"),
client_info=ClientInfo(
user_agent=f"dbt-bigquery-{dbt_version.version} dbt-invocation-id/{get_invocation_id()}"
),
client_options=ClientOptions(
quota_project_id=credentials.quota_project, api_endpoint=credentials.api_endpoint
),
Expand Down
5 changes: 4 additions & 1 deletion dbt-bigquery/tests/unit/test_bigquery_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from dbt.contracts.files import FileHash
from dbt.contracts.graph.manifest import ManifestStateCheck
from dbt.context.providers import RuntimeConfigObject, generate_runtime_macro_context
from dbt_common.invocation import get_invocation_id

from google.cloud.bigquery import AccessEntry

Expand Down Expand Up @@ -471,7 +472,9 @@ def test_api_endpoint_settable(self, MockClient, mock_auth_default, MockClientOp


class HasUserAgent:
PAT = re.compile(r"dbt-bigquery-\d+\.\d+\.\d+((a|b|rc)\d+)?")
PAT = re.compile(
r"dbt-bigquery-\d+\.\d+\.\d+((a|b|rc)\d+)? dbt-invocation-id/" + get_invocation_id()
)

def __eq__(self, other):
compare = getattr(other, "user_agent", "")
Expand Down
Loading