-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
47 changes: 47 additions & 0 deletions
47
instrumentation/opentelemetry-instrumentation-remoulade/tests/test_messages.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |