Skip to content

Audit and test opentelemetry-instrumentation-aiohttp-client NoOpTrace… #1612

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pkg_resources import iter_entry_points

from opentelemetry import context
from opentelemetry import trace as trace_api
from opentelemetry.instrumentation import aiohttp_client
from opentelemetry.instrumentation.aiohttp_client import (
AioHttpClientInstrumentor,
Expand Down Expand Up @@ -434,6 +435,18 @@ async def create_session(server: aiohttp.test_utils.TestServer):
run_with_test_server(create_session, self.URL, self.default_handler)
self.assert_spans(1)

def test_no_op_tracer_provider(self):
AioHttpClientInstrumentor().uninstrument()
AioHttpClientInstrumentor().instrument(
tracer_provider=trace_api.NoOpTracerProvider()
)

run_with_test_server(
self.get_default_request(), self.URL, self.default_handler
)
spans_list = self.memory_exporter.get_finished_spans()
self.assertEqual(len(spans_list), 0)

def test_uninstrument(self):
AioHttpClientInstrumentor().uninstrument()
run_with_test_server(
Expand Down