@@ -373,6 +373,11 @@ def test_exception_with_custom_properties(self, requests_mock):
373373 {
374374 'key_1' : 'value_1' ,
375375 'key_2' : 'value_2'
376+ },
377+ 'custom_measurements' :
378+ {
379+ 'measure_1' : 1 ,
380+ 'measure_2' : 2
376381 }
377382 }
378383 logger .exception ('Captured an exception.' , extra = properties )
@@ -382,6 +387,8 @@ def test_exception_with_custom_properties(self, requests_mock):
382387 self .assertTrue ('ZeroDivisionError' in post_body )
383388 self .assertTrue ('key_1' in post_body )
384389 self .assertTrue ('key_2' in post_body )
390+ self .assertTrue ('measure_1' in post_body )
391+ self .assertTrue ('measure_2' in post_body )
385392
386393 @mock .patch ('requests.post' , return_value = mock .Mock ())
387394 def test_export_empty (self , request_mock ):
@@ -436,13 +443,20 @@ def test_log_record_with_custom_properties(self, requests_mock):
436443 {
437444 'key_1' : 'value_1' ,
438445 'key_2' : 'value_2'
446+ },
447+ 'custom_measurements' :
448+ {
449+ 'measure_1' : 1 ,
450+ 'measure_2' : 2
439451 }
440452 })
441453 handler .close ()
442454 post_body = requests_mock .call_args_list [0 ][1 ]['data' ]
443455 self .assertTrue ('action' in post_body )
444456 self .assertTrue ('key_1' in post_body )
445457 self .assertTrue ('key_2' in post_body )
458+ self .assertTrue ('measure_1' in post_body )
459+ self .assertTrue ('measure_2' in post_body )
446460
447461 @mock .patch ('requests.post' , return_value = mock .Mock ())
448462 def test_log_with_invalid_custom_properties (self , requests_mock ):
@@ -454,7 +468,8 @@ def test_log_with_invalid_custom_properties(self, requests_mock):
454468 logger .addHandler (handler )
455469 logger .warning ('action_1_%s' , None )
456470 logger .warning ('action_2_%s' , 'arg' , extra = {
457- 'custom_dimensions' : 'not_a_dict'
471+ 'custom_dimensions' : 'not_a_dict' ,
472+ 'custom_measurements' : 'also_not'
458473 })
459474 logger .warning ('action_3_%s' , 'arg' , extra = {
460475 'notcustom_dimensions' : {'key_1' : 'value_1' }
@@ -468,6 +483,7 @@ def test_log_with_invalid_custom_properties(self, requests_mock):
468483 self .assertTrue ('action_3_arg' in post_body )
469484
470485 self .assertFalse ('not_a_dict' in post_body )
486+ self .assertFalse ('also_not' in post_body )
471487 self .assertFalse ('key_1' in post_body )
472488
473489 @mock .patch ('requests.post' , return_value = mock .Mock ())
0 commit comments