add a test for redis using NoOpTracerProvider
@@ -15,6 +15,7 @@ from unittest import mock
import redis
+from opentelemetry import trace
from opentelemetry.instrumentation.redis import RedisInstrumentor
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import SpanKind
@@ -146,3 +147,16 @@ class TestRedis(TestBase):
span = spans[0]
self.assertEqual(span.attributes.get(custom_attribute_name), "GET")
+
+ def test_no_op_tracer_provider(self):
+ RedisInstrumentor().uninstrument()
+ tracer_provider = trace.NoOpTracerProvider
+ RedisInstrumentor().instrument(tracer_provider=tracer_provider)
+
+ redis_client = redis.Redis()
+
+ with mock.patch.object(redis_client, "connection"):
+ redis_client.get("key")
+
+ spans = self.memory_exporter.get_finished_spans()
+ self.assertEqual(len(spans), 0)
