From d1dec9220b620cfaf4a4f04fde3d5bfc6e183a27 Mon Sep 17 00:00:00 2001 From: avzis <107620508+avzis@users.noreply.github.com> Date: Tue, 10 Jan 2023 18:23:48 +0200 Subject: [PATCH] add a test for urllib using NoOpTracerProvider (#1560) --- .../tests/test_urllib_integration.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py index 73c96ede1..5f1a5720b 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py +++ b/instrumentation/opentelemetry-instrumentation-urllib/tests/test_urllib_integration.py @@ -349,6 +349,15 @@ class RequestsIntegrationTestBase(abc.ABC): self.assertIn("response_hook_attr", span.attributes) self.assertEqual(span.attributes["response_hook_attr"], "value") + def test_no_op_tracer_provider(self): + URLLibInstrumentor().uninstrument() + tracer_provider = trace.NoOpTracerProvider + URLLibInstrumentor().instrument(tracer_provider=tracer_provider) + + result = self.perform_request(self.URL) + self.assertEqual(result.read(), b"Hello!") + self.assert_span(num_spans=0) + class TestRequestsIntegration(RequestsIntegrationTestBase, TestBase): @staticmethod