From e02d7c2a26c82a39fbb55663667821b90b1b36fc Mon Sep 17 00:00:00 2001 From: "dylan.yang" Date: Mon, 28 Jun 2021 11:16:13 -0400 Subject: [PATCH] ensure http.status_code is always a string --- datadog_lambda/trigger.py | 2 +- tests/test_trigger.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datadog_lambda/trigger.py b/datadog_lambda/trigger.py index 2dffd0b4..7271f239 100644 --- a/datadog_lambda/trigger.py +++ b/datadog_lambda/trigger.py @@ -214,4 +214,4 @@ def extract_http_status_code_tag(trigger_tags, response): elif hasattr(response, "status_code"): status_code = response.status_code - return status_code + return str(status_code) diff --git a/tests/test_trigger.py b/tests/test_trigger.py index 85bd4e6b..5c1c5d22 100644 --- a/tests/test_trigger.py +++ b/tests/test_trigger.py @@ -342,11 +342,11 @@ def test_extract_http_status_code_tag_from_response_dict(self): trigger_tags = {"function_trigger.event_source": "api-gateway"} response = {"statusCode": 403} status_code = extract_http_status_code_tag(trigger_tags, response) - self.assertEqual(status_code, 403) + self.assertEqual(status_code, "403") def test_extract_http_status_code_tag_from_response_object(self): trigger_tags = {"function_trigger.event_source": "api-gateway"} response = MagicMock(spec=["status_code"]) response.status_code = 403 status_code = extract_http_status_code_tag(trigger_tags, response) - self.assertEqual(status_code, 403) + self.assertEqual(status_code, "403")