Skip to content

feat: populate ibis version in user agent #140

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

Merged
merged 6 commits into from
Oct 26, 2023
Merged
Changes from 1 commit
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
23 changes: 18 additions & 5 deletions bigframes/session/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import google.cloud.bigquery_storage_v1
import google.cloud.functions_v2
import google.cloud.resourcemanager_v3
import ibis
import pydata_google_auth

import bigframes.version
Expand All @@ -49,6 +50,18 @@ def _get_default_credentials_with_project():
return pydata_google_auth.default(scopes=_SCOPES, use_local_webserver=False)


def _create_user_agent(application_name: str) -> str:
user_agent = []

if application_name:
user_agent.append(application_name)

user_agent_default_template = f"ibis/{ibis.__version__}"
user_agent.append(user_agent_default_template)

return " ".join(user_agent)


class ClientsProvider:
"""Provides client instances necessary to perform cloud operations."""

Expand Down Expand Up @@ -108,7 +121,7 @@ def bqclient(self):
),
)
bq_info = google.api_core.client_info.ClientInfo(
user_agent=self._application_name
user_agent=_create_user_agent(self._application_name)
)
self._bqclient = bigquery.Client(
client_info=bq_info,
Expand All @@ -131,7 +144,7 @@ def bqconnectionclient(self):
)
)
bqconnection_info = google.api_core.gapic_v1.client_info.ClientInfo(
user_agent=self._application_name
user_agent=_create_user_agent(self._application_name)
)
self._bqconnectionclient = (
google.cloud.bigquery_connection_v1.ConnectionServiceClient(
Expand All @@ -154,7 +167,7 @@ def bqstoragereadclient(self):
)
)
bqstorage_info = google.api_core.gapic_v1.client_info.ClientInfo(
user_agent=self._application_name
user_agent=_create_user_agent(self._application_name)
)
self._bqstoragereadclient = (
google.cloud.bigquery_storage_v1.BigQueryReadClient(
Expand All @@ -170,7 +183,7 @@ def bqstoragereadclient(self):
def cloudfunctionsclient(self):
if not self._cloudfunctionsclient:
functions_info = google.api_core.gapic_v1.client_info.ClientInfo(
user_agent=self._application_name
user_agent=_create_user_agent(self._application_name)
)
self._cloudfunctionsclient = (
google.cloud.functions_v2.FunctionServiceClient(
Expand All @@ -185,7 +198,7 @@ def cloudfunctionsclient(self):
def resourcemanagerclient(self):
if not self._resourcemanagerclient:
resourcemanager_info = google.api_core.gapic_v1.client_info.ClientInfo(
user_agent=self._application_name
user_agent=_create_user_agent(self._application_name)
)
self._resourcemanagerclient = (
google.cloud.resourcemanager_v3.ProjectsClient(
Expand Down