@@ -40,7 +40,8 @@ def test_function():
4040 add_code_attributes_to_span (mock_span , test_function )
4141
4242 # Verify function name attribute is set
43- mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , "test_function" )
43+ expected_function_name = f"{ test_function .__module__ } .{ test_function .__qualname__ } "
44+ mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , expected_function_name )
4445
4546 # Verify file path attribute is set
4647 expected_file_path = test_function .__code__ .co_filename
@@ -62,7 +63,8 @@ class TestClass:
6263 add_code_attributes_to_span (mock_span , TestClass )
6364
6465 # Verify class name attribute is set
65- mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , "TestClass" )
66+ expected_class_name = f"{ TestClass .__module__ } .{ TestClass .__qualname__ } "
67+ mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , expected_class_name )
6668
6769 # Verify file path attribute is set (classes have file paths too)
6870 mock_span .set_attribute .assert_any_call (CODE_FILE_PATH , __file__ )
@@ -150,7 +152,8 @@ def test_sync_function(arg1, arg2=None):
150152 self .assertEqual (result , "sync result: test_arg, test_kwarg" )
151153
152154 # Verify span attributes were set
153- self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , "test_sync_function" )
155+ expected_function_name = f"{ test_sync_function .__module__ } .{ test_sync_function .__qualname__ } "
156+ self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , expected_function_name )
154157
155158 @patch ("amazon.opentelemetry.distro.code_correlation.trace.get_current_span" )
156159 def test_decorator_async_function (self , mock_get_current_span ):
@@ -173,7 +176,8 @@ async def test_async_function(arg1, arg2=None):
173176 self .assertEqual (result , "async result: test_arg, test_kwarg" )
174177
175178 # Verify span attributes were set
176- self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , "test_async_function" )
179+ expected_function_name = f"{ test_async_function .__module__ } .{ test_async_function .__qualname__ } "
180+ self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , expected_function_name )
177181
178182 @patch ("amazon.opentelemetry.distro.code_correlation.trace.get_current_span" )
179183 def test_decorator_no_current_span (self , mock_get_current_span ):
@@ -255,7 +259,8 @@ def test_function():
255259 test_function ()
256260
257261 # Verify span attributes were still set before exception
258- self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , "test_function" )
262+ expected_function_name = f"{ test_function .__module__ } .{ test_function .__qualname__ } "
263+ self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , expected_function_name )
259264
260265 @patch ("amazon.opentelemetry.distro.code_correlation.trace.get_current_span" )
261266 def test_decorator_with_async_function_that_raises_exception (self , mock_get_current_span ):
@@ -276,7 +281,8 @@ async def test_async_function():
276281 loop .close ()
277282
278283 # Verify span attributes were still set before exception
279- self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , "test_async_function" )
284+ expected_function_name = f"{ test_async_function .__module__ } .{ test_async_function .__qualname__ } "
285+ self .mock_span .set_attribute .assert_any_call (CODE_FUNCTION_NAME , expected_function_name )
280286
281287 @patch ("amazon.opentelemetry.distro.code_correlation.add_code_attributes_to_span" )
282288 @patch ("amazon.opentelemetry.distro.code_correlation.trace.get_current_span" )
0 commit comments