mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-29 21:23:55 +08:00
@ -38,6 +38,7 @@ instruments = [
|
|||||||
]
|
]
|
||||||
test = [
|
test = [
|
||||||
"opentelemetry-instrumentation-aiohttp-client[instruments]",
|
"opentelemetry-instrumentation-aiohttp-client[instruments]",
|
||||||
|
"http-server-mock"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.entry-points.opentelemetry_instrumentor]
|
[project.entry-points.opentelemetry_instrumentor]
|
||||||
|
@ -23,6 +23,7 @@ from unittest import mock
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import aiohttp.test_utils
|
import aiohttp.test_utils
|
||||||
import yarl
|
import yarl
|
||||||
|
from http_server_mock import HttpServerMock
|
||||||
from pkg_resources import iter_entry_points
|
from pkg_resources import iter_entry_points
|
||||||
|
|
||||||
from opentelemetry import context
|
from opentelemetry import context
|
||||||
@ -313,18 +314,26 @@ class TestAioHttpIntegration(TestBase):
|
|||||||
def test_credential_removal(self):
|
def test_credential_removal(self):
|
||||||
trace_configs = [aiohttp_client.create_trace_config()]
|
trace_configs = [aiohttp_client.create_trace_config()]
|
||||||
|
|
||||||
url = "http://username:password@httpbin.org/status/200"
|
app = HttpServerMock("test_credential_removal")
|
||||||
with self.subTest(url=url):
|
|
||||||
|
|
||||||
async def do_request(url):
|
@app.route("/status/200")
|
||||||
async with aiohttp.ClientSession(
|
def index():
|
||||||
trace_configs=trace_configs,
|
return "hello"
|
||||||
) as session:
|
|
||||||
async with session.get(url):
|
|
||||||
pass
|
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
url = "http://username:password@localhost:5000/status/200"
|
||||||
loop.run_until_complete(do_request(url))
|
|
||||||
|
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(
|
self.assert_spans(
|
||||||
[
|
[
|
||||||
@ -333,7 +342,9 @@ class TestAioHttpIntegration(TestBase):
|
|||||||
(StatusCode.UNSET, None),
|
(StatusCode.UNSET, None),
|
||||||
{
|
{
|
||||||
SpanAttributes.HTTP_METHOD: "GET",
|
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),
|
SpanAttributes.HTTP_STATUS_CODE: int(HTTPStatus.OK),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user