2727 LoggingHandler ,
2828 LogRecordProcessor ,
2929)
30- from opentelemetry .semconv .trace import SpanAttributes
30+ from opentelemetry .semconv ._incubating .attributes import code_attributes
31+ from opentelemetry .semconv .attributes import exception_attributes
3132from opentelemetry .trace import INVALID_SPAN_CONTEXT
3233
3334
@@ -127,17 +128,19 @@ def test_log_record_user_attributes(self):
127128 self .assertEqual (len (log_record .attributes ), 4 )
128129 self .assertEqual (log_record .attributes ["http.status_code" ], 200 )
129130 self .assertTrue (
130- log_record .attributes [SpanAttributes . CODE_FILEPATH ].endswith (
131+ log_record .attributes [code_attributes . CODE_FILE_PATH ].endswith (
131132 "test_handler.py"
132133 )
133134 )
134135 self .assertEqual (
135- log_record .attributes [SpanAttributes . CODE_FUNCTION ],
136+ log_record .attributes [code_attributes . CODE_FUNCTION_NAME ],
136137 "test_log_record_user_attributes" ,
137138 )
138139 # The line of the log statement is not a constant (changing tests may change that),
139140 # so only check that the attribute is present.
140- self .assertTrue (SpanAttributes .CODE_LINENO in log_record .attributes )
141+ self .assertTrue (
142+ code_attributes .CODE_LINE_NUMBER in log_record .attributes
143+ )
141144 self .assertTrue (isinstance (log_record .attributes , BoundedAttributes ))
142145
143146 def test_log_record_exception (self ):
@@ -156,15 +159,15 @@ def test_log_record_exception(self):
156159 self .assertTrue (isinstance (log_record .body , str ))
157160 self .assertEqual (log_record .body , "Zero Division Error" )
158161 self .assertEqual (
159- log_record .attributes [SpanAttributes .EXCEPTION_TYPE ],
162+ log_record .attributes [exception_attributes .EXCEPTION_TYPE ],
160163 ZeroDivisionError .__name__ ,
161164 )
162165 self .assertEqual (
163- log_record .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
166+ log_record .attributes [exception_attributes .EXCEPTION_MESSAGE ],
164167 "division by zero" ,
165168 )
166169 stack_trace = log_record .attributes [
167- SpanAttributes .EXCEPTION_STACKTRACE
170+ exception_attributes .EXCEPTION_STACKTRACE
168171 ]
169172 self .assertIsInstance (stack_trace , str )
170173 self .assertTrue ("Traceback" in stack_trace )
@@ -189,15 +192,15 @@ def test_log_record_recursive_exception(self):
189192 self .assertIsNotNone (log_record )
190193 self .assertEqual (log_record .body , "Zero Division Error" )
191194 self .assertEqual (
192- log_record .attributes [SpanAttributes .EXCEPTION_TYPE ],
195+ log_record .attributes [exception_attributes .EXCEPTION_TYPE ],
193196 ZeroDivisionError .__name__ ,
194197 )
195198 self .assertEqual (
196- log_record .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
199+ log_record .attributes [exception_attributes .EXCEPTION_MESSAGE ],
197200 "division by zero" ,
198201 )
199202 stack_trace = log_record .attributes [
200- SpanAttributes .EXCEPTION_STACKTRACE
203+ exception_attributes .EXCEPTION_STACKTRACE
201204 ]
202205 self .assertIsInstance (stack_trace , str )
203206 self .assertTrue ("Traceback" in stack_trace )
@@ -219,12 +222,14 @@ def test_log_exc_info_false(self):
219222
220223 self .assertIsNotNone (log_record )
221224 self .assertEqual (log_record .body , "Zero Division Error" )
222- self .assertNotIn (SpanAttributes .EXCEPTION_TYPE , log_record .attributes )
223225 self .assertNotIn (
224- SpanAttributes .EXCEPTION_MESSAGE , log_record .attributes
226+ exception_attributes .EXCEPTION_TYPE , log_record .attributes
227+ )
228+ self .assertNotIn (
229+ exception_attributes .EXCEPTION_MESSAGE , log_record .attributes
225230 )
226231 self .assertNotIn (
227- SpanAttributes .EXCEPTION_STACKTRACE , log_record .attributes
232+ exception_attributes .EXCEPTION_STACKTRACE , log_record .attributes
228233 )
229234
230235 def test_log_record_exception_with_object_payload (self ):
@@ -246,15 +251,15 @@ def __str__(self):
246251 self .assertTrue (isinstance (log_record .body , str ))
247252 self .assertEqual (log_record .body , "CustomException stringified" )
248253 self .assertEqual (
249- log_record .attributes [SpanAttributes .EXCEPTION_TYPE ],
254+ log_record .attributes [exception_attributes .EXCEPTION_TYPE ],
250255 CustomException .__name__ ,
251256 )
252257 self .assertEqual (
253- log_record .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
258+ log_record .attributes [exception_attributes .EXCEPTION_MESSAGE ],
254259 "CustomException message" ,
255260 )
256261 stack_trace = log_record .attributes [
257- SpanAttributes .EXCEPTION_STACKTRACE
262+ exception_attributes .EXCEPTION_STACKTRACE
258263 ]
259264 self .assertIsInstance (stack_trace , str )
260265 self .assertTrue ("Traceback" in stack_trace )
0 commit comments