Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
perf(dbapi): set headers correctly for dynamic routing (#644)
  • Loading branch information
larkee committed Nov 18, 2021
1 parent 306a5ba commit d769ff8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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

0 comments on commit d769ff8

Please sign in to comment.