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 ):
@@ -155,15 +158,15 @@ def test_log_record_exception(self):
155158 self .assertIsNotNone (log_record )
156159 self .assertEqual (log_record .body , "Zero Division Error" )
157160 self .assertEqual (
158- log_record .attributes [SpanAttributes .EXCEPTION_TYPE ],
161+ log_record .attributes [exception_attributes .EXCEPTION_TYPE ],
159162 ZeroDivisionError .__name__ ,
160163 )
161164 self .assertEqual (
162- log_record .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
165+ log_record .attributes [exception_attributes .EXCEPTION_MESSAGE ],
163166 "division by zero" ,
164167 )
165168 stack_trace = log_record .attributes [
166- SpanAttributes .EXCEPTION_STACKTRACE
169+ exception_attributes .EXCEPTION_STACKTRACE
167170 ]
168171 self .assertIsInstance (stack_trace , str )
169172 self .assertTrue ("Traceback" in stack_trace )
@@ -188,15 +191,15 @@ def test_log_record_recursive_exception(self):
188191 self .assertIsNotNone (log_record )
189192 self .assertEqual (log_record .body , "Zero Division Error" )
190193 self .assertEqual (
191- log_record .attributes [SpanAttributes .EXCEPTION_TYPE ],
194+ log_record .attributes [exception_attributes .EXCEPTION_TYPE ],
192195 ZeroDivisionError .__name__ ,
193196 )
194197 self .assertEqual (
195- log_record .attributes [SpanAttributes .EXCEPTION_MESSAGE ],
198+ log_record .attributes [exception_attributes .EXCEPTION_MESSAGE ],
196199 "division by zero" ,
197200 )
198201 stack_trace = log_record .attributes [
199- SpanAttributes .EXCEPTION_STACKTRACE
202+ exception_attributes .EXCEPTION_STACKTRACE
200203 ]
201204 self .assertIsInstance (stack_trace , str )
202205 self .assertTrue ("Traceback" in stack_trace )
@@ -218,12 +221,14 @@ def test_log_exc_info_false(self):
218221
219222 self .assertIsNotNone (log_record )
220223 self .assertEqual (log_record .body , "Zero Division Error" )
221- self .assertNotIn (SpanAttributes .EXCEPTION_TYPE , log_record .attributes )
222224 self .assertNotIn (
223- SpanAttributes .EXCEPTION_MESSAGE , log_record .attributes
225+ exception_attributes .EXCEPTION_TYPE , log_record .attributes
226+ )
227+ self .assertNotIn (
228+ exception_attributes .EXCEPTION_MESSAGE , log_record .attributes
224229 )
225230 self .assertNotIn (
226- SpanAttributes .EXCEPTION_STACKTRACE , log_record .attributes
231+ exception_attributes .EXCEPTION_STACKTRACE , log_record .attributes
227232 )
228233
229234 def test_log_record_trace_correlation (self ):
0 commit comments