From 3bcc9fb5173600572479edae1c3071aa4bce6ee1 Mon Sep 17 00:00:00 2001 From: avzis <107620508+avzis@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:41:22 +0200 Subject: [PATCH] add a test for pymemcache using NoOpTracerProvider (#1650) Co-authored-by: Srikanth Chekuri --- .../tests/test_pymemcache.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py index 8b8b129ac..4e2909121 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py @@ -509,6 +509,19 @@ class PymemcacheClientTestCase( PymemcacheInstrumentor().instrument() + def test_no_op_tracer_provider(self): + PymemcacheInstrumentor().uninstrument() + tracer_provider = trace_api.NoOpTracerProvider() + PymemcacheInstrumentor().instrument(tracer_provider=tracer_provider) + + client = self.make_client([b"STORED\r\n"]) + result = client.set(b"key", b"value", noreply=False) + self.assertTrue(result) + + spans = self.memory_exporter.get_finished_spans() + assert spans is not None + self.assertEqual(len(spans), 0) + class PymemcacheHashClientTestCase(TestBase): """Tests for a patched pymemcache.client.hash.HashClient."""