Skip to content

Commit d769ff8

Browse files
authored
perf(dbapi): set headers correctly for dynamic routing (#644)
1 parent 306a5ba commit d769ff8

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

google/cloud/spanner_dbapi/connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,9 @@ def connect(
531531
"""
532532

533533
client_info = ClientInfo(
534-
user_agent=user_agent or DEFAULT_USER_AGENT, python_version=PY_VERSION
534+
user_agent=user_agent or DEFAULT_USER_AGENT,
535+
python_version=PY_VERSION,
536+
client_library_version=spanner.__version__,
535537
)
536538

537539
if isinstance(credentials, str):

google/cloud/spanner_dbapi/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
PY_VERSION = platform.python_version()
1919
VERSION = pkg_resources.get_distribution("google-cloud-spanner").version
20-
DEFAULT_USER_AGENT = "dbapi/" + VERSION
20+
DEFAULT_USER_AGENT = "gl-dbapi/" + VERSION

tests/system/test_dbapi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,11 @@ def test_user_agent(shared_instance, dbapi_database):
409409
conn = connect(shared_instance.name, dbapi_database.name)
410410
assert (
411411
conn.instance._client._client_info.user_agent
412-
== "dbapi/" + pkg_resources.get_distribution("google-cloud-spanner").version
412+
== "gl-dbapi/" + pkg_resources.get_distribution("google-cloud-spanner").version
413+
)
414+
assert (
415+
conn.instance._client._client_info.client_library_version
416+
== pkg_resources.get_distribution("google-cloud-spanner").version
413417
)
414418

415419

0 commit comments

Comments
 (0)