Skip to content

Commit

Permalink
add a test for redis using NoOpTracerProvider (open-telemetry#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
avzis authored Jan 9, 2023
1 parent 6d1550b commit 494bf09
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import redis

from opentelemetry import trace
from opentelemetry.instrumentation.redis import RedisInstrumentor
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import SpanKind
Expand Down Expand Up @@ -146,3 +147,16 @@ def request_hook(span, conn, args, kwargs):

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)

0 comments on commit 494bf09

Please sign in to comment.