File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,32 @@ def test_lambda_metric_flush_to_log(self):
92
92
93
93
del os .environ ["DD_FLUSH_TO_LOG" ]
94
94
95
+ @patch ("datadog_lambda.metric.logger.warning" )
96
+ def test_lambda_metric_invalid_metric_name_none (self , mock_logger_warning ):
97
+ lambda_metric (None , 1 )
98
+ self .mock_metric_lambda_stats .distribution .assert_not_called ()
99
+ mock_logger_warning .assert_called_once_with (
100
+ "Ignoring metric submission. Invalid metric name: %s" , None
101
+ )
102
+
103
+ @patch ("datadog_lambda.metric.logger.warning" )
104
+ def test_lambda_metric_invalid_metric_name_not_string (self , mock_logger_warning ):
105
+ lambda_metric (123 , 1 )
106
+ self .mock_metric_lambda_stats .distribution .assert_not_called ()
107
+ mock_logger_warning .assert_called_once_with (
108
+ "Ignoring metric submission. Invalid metric name: %s" , 123
109
+ )
110
+
111
+ @patch ("datadog_lambda.metric.logger.warning" )
112
+ def test_lambda_metric_non_numeric_value (self , mock_logger_warning ):
113
+ lambda_metric ("test.non_numeric" , "oops" )
114
+ self .mock_metric_lambda_stats .distribution .assert_not_called ()
115
+ mock_logger_warning .assert_called_once_with (
116
+ "Ignoring metric submission for metric '%s' because the value is not numeric: %r" ,
117
+ "test.non_numeric" ,
118
+ "oops" ,
119
+ )
120
+
95
121
96
122
class TestFlushThreadStats (unittest .TestCase ):
97
123
def setUp (self ):
You can’t perform that action at this time.
0 commit comments