Skip to content

Commit

Permalink
Fix Itests results order
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0Aja committed Dec 4, 2023
1 parent 379dd1e commit 187bd4b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion aws/logs_monitoring/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@ def extract_ddtags_from_message(event):

# Extract service tag from message.ddtags if exists
if "service" in extracted_ddtags:
event[DD_SERVICE] = next(tag[8:] for tag in extracted_ddtags.split(",") if tag.startswith("service:"))
event[DD_SERVICE] = next(
tag[8:]
for tag in extracted_ddtags.split(",")
if tag.startswith("service:")
)
event[DD_CUSTOM_TAGS] = ",".join(
[
tag
Expand Down
12 changes: 8 additions & 4 deletions aws/logs_monitoring/tests/test_lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ def test_extract_trace_payload_valid_trace(self):


class TestMergeMessageTags(unittest.TestCase):
message_tags = (
'{"ddtags":"service:my_application_service,custom_tag_1:value1"}'
)
message_tags = '{"ddtags":"service:my_application_service,custom_tag_1:value1"}'
custom_tags = "custom_tag_2:value2,service:my_custom_service"

def test_extract_ddtags_from_message_str(self):
Expand Down Expand Up @@ -361,7 +359,13 @@ def test_extract_ddtags_from_message_dict(self):

def test_extract_ddtags_from_message_service_tag_setting(self):
loaded_message_tags = json.loads(self.message_tags)
loaded_message_tags["ddtags"] = ",".join([tag for tag in loaded_message_tags["ddtags"].split(",") if not tag.startswith("service:")])
loaded_message_tags["ddtags"] = ",".join(
[
tag
for tag in loaded_message_tags["ddtags"].split(",")
if not tag.startswith("service:")
]
)
event = {
"message": loaded_message_tags,
"ddtags": self.custom_tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"ddsource": "cloudwatch",
"ddsourcecategory": "aws",
"ddtags": "custom_tag1:value1,custom_tag2:value2,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,forwardername:test",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,custom_tag1:value1,custom_tag2:value2",
"host": "testLogGroup",
"id": "eventId1",
"message": "{\"message\": \"hello world\"}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"ddsource": "cloudwatch",
"ddsourcecategory": "aws",
"ddtags": "forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,forwardername:test,service:myservice",
"ddtags": "forwardername:test,forwarder_memorysize:1536,forwarder_version:<redacted from snapshot>,service:myservice",
"host": "testLogGroup",
"id": "eventId1",
"message": "{\"message\": \"hello world\"}",
Expand Down

0 comments on commit 187bd4b

Please sign in to comment.