Skip to content

Commit 06eb8c5

Browse files
committed
Add back the assert_span_count method
1 parent 3a9f1d1 commit 06eb8c5

File tree

1 file changed

+27
-0
lines changed
  • instrumentation/opentelemetry-instrumentation-redis/tests

1 file changed

+27
-0
lines changed

instrumentation/opentelemetry-instrumentation-redis/tests/test_redis.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535

3636

3737
class TestRedis(TestBase):
38+
def assert_span_count(self, count: int):
39+
"""
40+
Assert that the memory exporter has the expected number of spans.
41+
Returns the spans list if assertion passes
42+
"""
43+
spans = self.memory_exporter.get_finished_spans()
44+
self.assertEqual(len(spans), count)
45+
return spans
46+
3847
def setUp(self):
3948
super().setUp()
4049
RedisInstrumentor().instrument(tracer_provider=self.tracer_provider)
@@ -387,6 +396,15 @@ def redis_operations():
387396

388397

389398
class TestRedisAsync(TestBase, IsolatedAsyncioTestCase):
399+
def assert_span_count(self, count: int):
400+
"""
401+
Assert that the memory exporter has the expected number of spans.
402+
Returns the spans list if assertion passes
403+
"""
404+
spans = self.memory_exporter.get_finished_spans()
405+
self.assertEqual(len(spans), count)
406+
return spans
407+
390408
def setUp(self):
391409
super().setUp()
392410
self.instrumentor = RedisInstrumentor()
@@ -530,6 +548,15 @@ def response_hook(span, conn, args):
530548

531549

532550
class TestRedisInstance(TestBase):
551+
def assert_span_count(self, count: int):
552+
"""
553+
Assert that the memory exporter has the expected number of spans.
554+
Returns the spans list if assertion passes
555+
"""
556+
spans = self.memory_exporter.get_finished_spans()
557+
self.assertEqual(len(spans), count)
558+
return spans
559+
533560
def setUp(self):
534561
super().setUp()
535562
self.client = fakeredis.FakeStrictRedis()

0 commit comments

Comments
 (0)