@@ -92,6 +92,42 @@ def test_task(self):
92
92
self .assertEqual (consumer .parent .span_id , producer .context .span_id )
93
93
self .assertEqual (consumer .context .trace_id , producer .context .trace_id )
94
94
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
+
95
131
def test_task_raises (self ):
96
132
CeleryInstrumentor ().instrument ()
97
133
0 commit comments