@@ -465,13 +465,39 @@ def test_label_forwarding_disabled():
465465
466466
467467@override_application_settings ({
468- "application_logging.forwarding.custom_attributes" : [("custom_attr_1" , "value" ), ("custom_attr_2" , "a" * 256 )],
468+ "application_logging.forwarding.custom_attributes" : [("custom_attr_1" , "value 1 " ), ("custom_attr_2" , "value 2" )],
469469})
470470@background_task ()
471- def test_global_custom_attribute_forwarding ():
471+ def test_global_custom_attribute_forwarding_enabled ():
472472 txn = current_transaction ()
473473 session = list (txn .application ._agent ._applications .values ())[0 ]._active_session
474474
475475 common = session .get_log_events_common_block ()
476- # Both attrs should appear, and the 2nd attr should be truncated to the max user attribute length
477- assert common == {"custom_attr_1" : "value" , "custom_attr_2" : "a" * 255 }
476+ # Both attrs should appear
477+ assert common == {"custom_attr_1" : "value 1" , "custom_attr_2" : "value 2" }
478+
479+
480+ @override_application_settings ({
481+ "application_logging.forwarding.custom_attributes" : [("custom_attr_1" , "a" * 256 )],
482+ })
483+ @background_task ()
484+ def test_global_custom_attribute_forwarding_truncation ():
485+ txn = current_transaction ()
486+ session = list (txn .application ._agent ._applications .values ())[0 ]._active_session
487+
488+ common = session .get_log_events_common_block ()
489+ # Attribute value should be truncated to the max user attribute length
490+ assert common == {"custom_attr_1" : "a" * 255 }
491+
492+
493+ @override_application_settings ({
494+ "application_logging.forwarding.custom_attributes" : [(f"custom_attr_{ i + 1 } " , "value" ) for i in range (129 )],
495+ })
496+ @background_task ()
497+ def test_global_custom_attribute_forwarding_max_num_attrs ():
498+ txn = current_transaction ()
499+ session = list (txn .application ._agent ._applications .values ())[0 ]._active_session
500+
501+ common = session .get_log_events_common_block ()
502+ # Should be truncated to the max number of user attributes
503+ assert common == {f"custom_attr_{ i + 1 } " : "value" for i in range (128 )}
0 commit comments