Skip to content

Commit

Permalink
fix failed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nozik committed Feb 4, 2022
1 parent 3a43261 commit fb0e0fb
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,17 @@ async def _perform_request():

return _async_call(_perform_request())

def test_basic_multiple(self):
# We need to create separate clients because in httpx >= 0.19,
# closing the client after "with" means the second http call fails
self.perform_request(
self.URL, client=self.create_client(self.transport)
)
self.perform_request(
self.URL, client=self.create_client(self.transport)
)
self.assert_span(num_spans=2)


class TestSyncInstrumentationIntegration(BaseTestCases.BaseInstrumentorTest):
def create_client(
Expand All @@ -642,6 +653,13 @@ class TestAsyncInstrumentationIntegration(BaseTestCases.BaseInstrumentorTest):
request_hook = staticmethod(_async_request_hook)
no_update_request_hook = staticmethod(_async_no_update_request_hook)

def setUp(self):
super().setUp()
HTTPXClientInstrumentor().instrument()
self.client = self.create_client()
self.client2 = self.create_client()
HTTPXClientInstrumentor().uninstrument()

def create_client(
self,
transport: typing.Optional[AsyncOpenTelemetryTransport] = None,
Expand All @@ -664,3 +682,10 @@ async def _perform_request():
return await _client.request(method, url, headers=headers)

return _async_call(_perform_request())

def test_basic_multiple(self):
# We need to create separate clients because in httpx >= 0.19,
# closing the client after "with" means the second http call fails
self.perform_request(self.URL, client=self.client)
self.perform_request(self.URL, client=self.client2)
self.assert_span(num_spans=2)

0 comments on commit fb0e0fb

Please sign in to comment.