2020from opentelemetry import baggage , context
2121from opentelemetry .instrumentation .celery import CeleryInstrumentor , utils
2222from opentelemetry .instrumentation .utils import unwrap
23- from opentelemetry .semconv .trace import SpanAttributes
23+ from opentelemetry .semconv ._incubating .attributes import (
24+ exception_attributes as ExceptionAttributes ,
25+ )
26+ from opentelemetry .semconv ._incubating .attributes import (
27+ messaging_attributes as SpanAttributes ,
28+ )
2429from opentelemetry .test .test_base import TestBase
2530from opentelemetry .trace import SpanKind , StatusCode
2631
@@ -65,7 +70,7 @@ def test_task(self):
6570 {
6671 "celery.action" : "run" ,
6772 "celery.state" : "SUCCESS" ,
68- SpanAttributes .MESSAGING_DESTINATION : "celery" ,
73+ SpanAttributes .MESSAGING_DESTINATION_NAME : "celery" ,
6974 "celery.task_name" : "tests.celery_test_tasks.task_add" ,
7075 },
7176 )
@@ -83,8 +88,7 @@ def test_task(self):
8388 {
8489 "celery.action" : "apply_async" ,
8590 "celery.task_name" : "tests.celery_test_tasks.task_add" ,
86- SpanAttributes .MESSAGING_DESTINATION_KIND : "queue" ,
87- SpanAttributes .MESSAGING_DESTINATION : "celery" ,
91+ SpanAttributes .MESSAGING_DESTINATION_NAME : "celery" ,
8892 },
8993 )
9094
@@ -117,7 +121,7 @@ def test_task_raises(self):
117121 {
118122 "celery.action" : "run" ,
119123 "celery.state" : "FAILURE" ,
120- SpanAttributes .MESSAGING_DESTINATION : "celery" ,
124+ SpanAttributes .MESSAGING_DESTINATION_NAME : "celery" ,
121125 "celery.task_name" : "tests.celery_test_tasks.task_raises" ,
122126 },
123127 )
@@ -127,15 +131,17 @@ def test_task_raises(self):
127131 self .assertEqual (1 , len (consumer .events ))
128132 event = consumer .events [0 ]
129133
130- self .assertIn (SpanAttributes .EXCEPTION_STACKTRACE , event .attributes )
134+ self .assertIn (
135+ ExceptionAttributes .EXCEPTION_STACKTRACE , event .attributes
136+ )
131137
132138 # TODO: use plain assertEqual after 1.25 is released (https://github.com/open-telemetry/opentelemetry-python/pull/3837)
133139 self .assertIn (
134- "CustomError" , event .attributes [SpanAttributes .EXCEPTION_TYPE ]
140+ "CustomError" , event .attributes [ExceptionAttributes .EXCEPTION_TYPE ]
135141 )
136142
137143 self .assertEqual (
138- event .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
144+ event .attributes [ExceptionAttributes .EXCEPTION_MESSAGE ],
139145 "The task failed!" ,
140146 )
141147
@@ -148,8 +154,7 @@ def test_task_raises(self):
148154 {
149155 "celery.action" : "apply_async" ,
150156 "celery.task_name" : "tests.celery_test_tasks.task_raises" ,
151- SpanAttributes .MESSAGING_DESTINATION_KIND : "queue" ,
152- SpanAttributes .MESSAGING_DESTINATION : "celery" ,
157+ SpanAttributes .MESSAGING_DESTINATION_NAME : "celery" ,
153158 },
154159 )
155160
0 commit comments