20
20
from opentelemetry import baggage , context
21
21
from opentelemetry .instrumentation .celery import CeleryInstrumentor , utils
22
22
from 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
+ )
24
29
from opentelemetry .test .test_base import TestBase
25
30
from opentelemetry .trace import SpanKind , StatusCode
26
31
@@ -65,7 +70,7 @@ def test_task(self):
65
70
{
66
71
"celery.action" : "run" ,
67
72
"celery.state" : "SUCCESS" ,
68
- SpanAttributes .MESSAGING_DESTINATION : "celery" ,
73
+ SpanAttributes .MESSAGING_DESTINATION_NAME : "celery" ,
69
74
"celery.task_name" : "tests.celery_test_tasks.task_add" ,
70
75
},
71
76
)
@@ -83,8 +88,7 @@ def test_task(self):
83
88
{
84
89
"celery.action" : "apply_async" ,
85
90
"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" ,
88
92
},
89
93
)
90
94
@@ -117,7 +121,7 @@ def test_task_raises(self):
117
121
{
118
122
"celery.action" : "run" ,
119
123
"celery.state" : "FAILURE" ,
120
- SpanAttributes .MESSAGING_DESTINATION : "celery" ,
124
+ SpanAttributes .MESSAGING_DESTINATION_NAME : "celery" ,
121
125
"celery.task_name" : "tests.celery_test_tasks.task_raises" ,
122
126
},
123
127
)
@@ -127,15 +131,17 @@ def test_task_raises(self):
127
131
self .assertEqual (1 , len (consumer .events ))
128
132
event = consumer .events [0 ]
129
133
130
- self .assertIn (SpanAttributes .EXCEPTION_STACKTRACE , event .attributes )
134
+ self .assertIn (
135
+ ExceptionAttributes .EXCEPTION_STACKTRACE , event .attributes
136
+ )
131
137
132
138
# TODO: use plain assertEqual after 1.25 is released (https://github.com/open-telemetry/opentelemetry-python/pull/3837)
133
139
self .assertIn (
134
- "CustomError" , event .attributes [SpanAttributes .EXCEPTION_TYPE ]
140
+ "CustomError" , event .attributes [ExceptionAttributes .EXCEPTION_TYPE ]
135
141
)
136
142
137
143
self .assertEqual (
138
- event .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
144
+ event .attributes [ExceptionAttributes .EXCEPTION_MESSAGE ],
139
145
"The task failed!" ,
140
146
)
141
147
@@ -148,8 +154,7 @@ def test_task_raises(self):
148
154
{
149
155
"celery.action" : "apply_async" ,
150
156
"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" ,
153
158
},
154
159
)
155
160
0 commit comments