Skip to content

Commit 437648e

Browse files
chore: review comments
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
1 parent 8e13482 commit 437648e

File tree

1 file changed

+4
-36
lines changed
  • instrumentation/opentelemetry-instrumentation-celery/tests

1 file changed

+4
-36
lines changed

instrumentation/opentelemetry-instrumentation-celery/tests/test_tasks.py

+4-36
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def test_task(self):
6767
"celery.state": "SUCCESS",
6868
SpanAttributes.MESSAGING_DESTINATION: "celery",
6969
"celery.task_name": "tests.celery_test_tasks.task_add",
70+
SpanAttributes.MESSAGING_SYSTEM: "celery",
7071
},
7172
)
7273

@@ -85,49 +86,14 @@ def test_task(self):
8586
"celery.task_name": "tests.celery_test_tasks.task_add",
8687
SpanAttributes.MESSAGING_DESTINATION_KIND: "queue",
8788
SpanAttributes.MESSAGING_DESTINATION: "celery",
89+
SpanAttributes.MESSAGING_SYSTEM: "celery",
8890
},
8991
)
9092

9193
self.assertNotEqual(consumer.parent, producer.context)
9294
self.assertEqual(consumer.parent.span_id, producer.context.span_id)
9395
self.assertEqual(consumer.context.trace_id, producer.context.trace_id)
9496

95-
def test_queue_name(self):
96-
CeleryInstrumentor().instrument()
97-
98-
result = task_add.delay(1, 2)
99-
100-
timeout = time.time() + 60 * 1 # 1 minutes from now
101-
while not result.ready():
102-
if time.time() > timeout:
103-
break
104-
time.sleep(0.05)
105-
106-
spans = self.sorted_spans(self.memory_exporter.get_finished_spans())
107-
self.assertEqual(len(spans), 2)
108-
109-
consumer, producer = spans
110-
111-
self.assertEqual(consumer.name, "run/tests.celery_test_tasks.task_add")
112-
self.assertEqual(consumer.kind, SpanKind.CONSUMER)
113-
self.assertSpanHasAttributes(
114-
consumer,
115-
{
116-
"celery.action": "run",
117-
"celery.state": "SUCCESS",
118-
SpanAttributes.MESSAGING_SYSTEM: "celery",
119-
"celery.task_name": "tests.celery_test_tasks.task_add",
120-
},
121-
)
122-
self.assertSpanHasAttributes(
123-
producer,
124-
{
125-
"celery.action": "apply_async",
126-
"celery.task_name": "tests.celery_test_tasks.task_add",
127-
SpanAttributes.MESSAGING_SYSTEM: "celery",
128-
},
129-
)
130-
13197
def test_task_raises(self):
13298
CeleryInstrumentor().instrument()
13399

@@ -155,6 +121,7 @@ def test_task_raises(self):
155121
"celery.state": "FAILURE",
156122
SpanAttributes.MESSAGING_DESTINATION: "celery",
157123
"celery.task_name": "tests.celery_test_tasks.task_raises",
124+
SpanAttributes.MESSAGING_SYSTEM: "celery",
158125
},
159126
)
160127

@@ -186,6 +153,7 @@ def test_task_raises(self):
186153
"celery.task_name": "tests.celery_test_tasks.task_raises",
187154
SpanAttributes.MESSAGING_DESTINATION_KIND: "queue",
188155
SpanAttributes.MESSAGING_DESTINATION: "celery",
156+
SpanAttributes.MESSAGING_SYSTEM: "celery",
189157
},
190158
)
191159

0 commit comments

Comments
 (0)