Skip to content
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

perf(dbapi): set headers correctly for dynamic routing #644

Merged
merged 4 commits into from Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion google/cloud/spanner_dbapi/connection.py
Expand Up @@ -531,7 +531,9 @@ def connect(
"""

client_info = ClientInfo(
user_agent=user_agent or DEFAULT_USER_AGENT, python_version=PY_VERSION
user_agent=user_agent or DEFAULT_USER_AGENT,
python_version=PY_VERSION,
client_library_version=spanner.__version__,
)

if isinstance(credentials, str):
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/spanner_dbapi/version.py
Expand Up @@ -17,4 +17,4 @@

PY_VERSION = platform.python_version()
VERSION = pkg_resources.get_distribution("google-cloud-spanner").version
DEFAULT_USER_AGENT = "dbapi/" + VERSION
DEFAULT_USER_AGENT = "gl-dbapi/" + VERSION
6 changes: 5 additions & 1 deletion tests/system/test_dbapi.py
Expand Up @@ -409,7 +409,11 @@ def test_user_agent(shared_instance, dbapi_database):
conn = connect(shared_instance.name, dbapi_database.name)
assert (
conn.instance._client._client_info.user_agent
== "dbapi/" + pkg_resources.get_distribution("google-cloud-spanner").version
== "gl-dbapi/" + pkg_resources.get_distribution("google-cloud-spanner").version
)
assert (
conn.instance._client._client_info.client_library_version
== pkg_resources.get_distribution("google-cloud-spanner").version
)


Expand Down