|
35 | 35 |
|
36 | 36 |
|
37 | 37 | 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 | + |
38 | 47 | def setUp(self):
|
39 | 48 | super().setUp()
|
40 | 49 | RedisInstrumentor().instrument(tracer_provider=self.tracer_provider)
|
@@ -387,6 +396,15 @@ def redis_operations():
|
387 | 396 |
|
388 | 397 |
|
389 | 398 | 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 | + |
390 | 408 | def setUp(self):
|
391 | 409 | super().setUp()
|
392 | 410 | self.instrumentor = RedisInstrumentor()
|
@@ -530,6 +548,15 @@ def response_hook(span, conn, args):
|
530 | 548 |
|
531 | 549 |
|
532 | 550 | 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 | + |
533 | 560 | def setUp(self):
|
534 | 561 | super().setUp()
|
535 | 562 | self.client = fakeredis.FakeStrictRedis()
|
|
0 commit comments