Skip to content

Commit

Permalink
feat: add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-natan committed Apr 20, 2022
1 parent 56a7c2d commit 73da355
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import remoulade
from remoulade.brokers.local import LocalBroker
from remoulade.results import Results
from remoulade.results.backends import LocalBackend
from opentelemetry.instrumentation.remoulade import RemouladeInstrumentor
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import SpanKind



@remoulade.actor
def actor_multiply(x, y):
return x * y


class TestRemouladeInstrumentation(TestBase):
def setUp(self):
super().setUp()

broker = LocalBroker()

# Should a backend be added to wait for the result ?
# result_backend = LocalBackend()
# broker.add_middleware(Results(backend=result_backend))
remoulade.set_broker(broker)
RemouladeInstrumentor().instrument()

broker.declare_actor(actor_multiply)

def test_message(self):
message = actor_multiply.send(1, 2)
# result = message.result.get(block=True)

spans = self.sorted_spans(self.memory_exporter.get_finished_spans())
self.assertEqual(len(spans), 2)

consumer, producer = spans

self.assertEqual(consumer.name, "remoulade/process")
self.assertEqual(consumer.kind, SpanKind.CONSUMER)

self.assertEqual(producer.name, "remoulade/send")
self.assertEqual(producer.kind, SpanKind.PRODUCER)

self.assertNotEqual(consumer.parent, producer.context)
self.assertEqual(consumer.parent.span_id, producer.context.span_id)
self.assertEqual(consumer.context.trace_id, producer.context.trace_id)

0 comments on commit 73da355

Please sign in to comment.