-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
73 changed files
with
1,514 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import aiohttp | ||
import aiohttp.test_utils | ||
import yarl | ||
from http_server_mock import HttpServerMock | ||
from pkg_resources import iter_entry_points | ||
|
||
from opentelemetry import context | ||
|
@@ -118,7 +119,7 @@ def test_status_codes(self): | |
self.assert_spans( | ||
[ | ||
( | ||
"HTTP GET", | ||
"GET", | ||
(span_status, None), | ||
{ | ||
SpanAttributes.HTTP_METHOD: "GET", | ||
|
@@ -212,7 +213,7 @@ def strip_query_params(url: yarl.URL) -> str: | |
self.assert_spans( | ||
[ | ||
( | ||
"HTTP GET", | ||
"GET", | ||
(StatusCode.UNSET, None), | ||
{ | ||
SpanAttributes.HTTP_METHOD: "GET", | ||
|
@@ -246,7 +247,7 @@ async def do_request(url): | |
self.assert_spans( | ||
[ | ||
( | ||
"HTTP GET", | ||
"GET", | ||
(expected_status, None), | ||
{ | ||
SpanAttributes.HTTP_METHOD: "GET", | ||
|
@@ -273,7 +274,7 @@ async def request_handler(request): | |
self.assert_spans( | ||
[ | ||
( | ||
"HTTP GET", | ||
"GET", | ||
(StatusCode.ERROR, None), | ||
{ | ||
SpanAttributes.HTTP_METHOD: "GET", | ||
|
@@ -300,7 +301,7 @@ async def request_handler(request): | |
self.assert_spans( | ||
[ | ||
( | ||
"HTTP GET", | ||
"GET", | ||
(StatusCode.ERROR, None), | ||
{ | ||
SpanAttributes.HTTP_METHOD: "GET", | ||
|
@@ -313,27 +314,37 @@ async def request_handler(request): | |
def test_credential_removal(self): | ||
trace_configs = [aiohttp_client.create_trace_config()] | ||
|
||
url = "http://username:[email protected]/status/200" | ||
with self.subTest(url=url): | ||
app = HttpServerMock("test_credential_removal") | ||
|
||
async def do_request(url): | ||
async with aiohttp.ClientSession( | ||
trace_configs=trace_configs, | ||
) as session: | ||
async with session.get(url): | ||
pass | ||
@app.route("/status/200") | ||
def index(): | ||
return "hello" | ||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(do_request(url)) | ||
url = "http://username:password@localhost:5000/status/200" | ||
|
||
with app.run("localhost", 5000): | ||
with self.subTest(url=url): | ||
|
||
async def do_request(url): | ||
async with aiohttp.ClientSession( | ||
trace_configs=trace_configs, | ||
) as session: | ||
async with session.get(url): | ||
pass | ||
|
||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(do_request(url)) | ||
|
||
self.assert_spans( | ||
[ | ||
( | ||
"HTTP GET", | ||
"GET", | ||
(StatusCode.UNSET, None), | ||
{ | ||
SpanAttributes.HTTP_METHOD: "GET", | ||
SpanAttributes.HTTP_URL: "http://httpbin.org/status/200", | ||
SpanAttributes.HTTP_URL: ( | ||
"http://localhost:5000/status/200" | ||
), | ||
SpanAttributes.HTTP_STATUS_CODE: int(HTTPStatus.OK), | ||
}, | ||
) | ||
|
@@ -380,6 +391,7 @@ def test_instrument(self): | |
self.get_default_request(), self.URL, self.default_handler | ||
) | ||
span = self.assert_spans(1) | ||
self.assertEqual("GET", span.name) | ||
self.assertEqual("GET", span.attributes[SpanAttributes.HTTP_METHOD]) | ||
self.assertEqual( | ||
f"http://{host}:{port}/test-path", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.