Skip to content

Commit

Permalink
Merge pull request #610 from vespa-engine/jobergum/user-agent
Browse files Browse the repository at this point in the history
Jobergum/user agent
  • Loading branch information
jonmv committed Nov 1, 2023
2 parents dd09691 + 6981953 commit 66d7ad1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vespa/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ def _open_http_session(self):
return

self.http_session = Session()
self.http_session.headers.update({"User-Agent": "pyvespa syncio client"})
self.http_session.mount("https://", self.adapter)
self.http_session.mount("http://", self.adapter)
if self.app.vespa_cloud_secret_token:
Expand Down Expand Up @@ -1271,7 +1272,10 @@ def __init__(
self.connections = connections
self.total_timeout = total_timeout
if self.app.vespa_cloud_secret_token:
self.headers = {"Authorization": f"Bearer {self.app.vespa_cloud_secret_token}"}
self.headers = {
"Authorization": f"Bearer {self.app.vespa_cloud_secret_token}",
"User-Agent": "pyvespa asyncio client",
}

async def __aenter__(self):
await self._open_aiohttp_session()
Expand All @@ -1296,7 +1300,8 @@ async def _open_aiohttp_session(self):
)
else:
self.aiohttp_session = aiohttp.ClientSession(
connector=conn, timeout=aiohttp.ClientTimeout(total=self.total_timeout)
connector=conn, timeout=aiohttp.ClientTimeout(total=self.total_timeout),
headers={"User-Agent": "pyvespa asyncio client"}
)
return self.aiohttp_session

Expand Down
1 change: 1 addition & 0 deletions vespa/test_integration_vespa_cloud_vector_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def tearDown(self) -> None:
self.app.delete_all_docs(
content_cluster_name="vector_content", schema="vector",namespace="benchmark"
)
time.sleep(5)
with self.app.syncio() as sync_session:
response:VespaResponse = sync_session.query(
{
Expand Down

0 comments on commit 66d7ad1

Please sign in to comment.