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

This commit is contained in:
Akochavi 2023-02-13 13:00:24 +02:00 committed by GitHub
parent 260df4dc6d
commit 0a4b3b4a0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import yarl
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,
@ -434,6 +435,18 @@ class TestAioHttpClientInstrumentor(TestBase):
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(