Skip to content

Commit 041825b

Browse files
committed
Parse data out of input events to include in responses
1 parent be6186f commit 041825b

39 files changed

+219
-40
lines changed

scripts/run_integration_tests.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ script_start_time=$(date --iso-8601=seconds)
2424

2525
mismatch_found=false
2626

27-
echo "Start time is $script_start_time"
28-
2927
if [ -z "$DD_API_KEY" ]; then
3028
echo "No DD_API_KEY env var set, exiting"
3129
exit 1

tests/integration/handle.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,29 @@
66

77
@datadog_lambda_wrapper
88
def handle(event, context):
9+
# Parse request ID and record ids out of the event to include in the response
10+
request_id = event.get("requestContext", {}).get("requestId")
11+
event_records = event.get("Records", [])
12+
13+
record_ids = []
14+
for record in event_records:
15+
# SQS
16+
if record.get("messageId"):
17+
record_ids.append(record["messageId"])
18+
# SNS
19+
if record.get("Sns", {}).get("MessageId"):
20+
record_ids.append(record["Sns"]["MessageId"])
21+
922
lambda_metric("hello.dog", 1, tags=["team:serverless", "role:hello"])
1023
lambda_metric(
1124
"tests.integration.count", 21, tags=["test:integration", "role:hello"]
1225
)
13-
return {"statusCode": 200, "body": "hello, dog!"}
26+
27+
return {
28+
"statusCode": 200,
29+
"body": {
30+
"message": "hello, dog!",
31+
"request_id": request_id,
32+
"event_record_ids": record_ids,
33+
},
34+
}

tests/integration/http_requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def handle(event, context):
1515
us_response = requests.get("https://ip-ranges.datadoghq.com/")
1616
eu_response = requests.get("https://ip-ranges.datadoghq.eu/")
1717

18-
return {"statusCode": 200, "body": "hello, dog!"}
18+
return {"statusCode": 200, "body": {"message": "hello, dog!"}}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
2-
"body": "hello, dog!",
2+
"body": {
3+
"message": "hello, dog!",
4+
"event_record_ids": [],
5+
"request_id": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9"
6+
},
37
"statusCode": 200
48
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
2-
"body": "hello, dog!",
2+
"body": {
3+
"message": "hello, dog!",
4+
"event_record_ids": [
5+
"95df01b4-ee98-5cb9-9903-4c221d41eb5e"
6+
],
7+
"request_id": null
8+
},
39
"statusCode": 200
410
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
2-
"body": "hello, dog!",
2+
"body": {
3+
"message": "hello, dog!",
4+
"event_record_ids": [
5+
"059f36b4-87a3-44ab-83d2-661975830a7d",
6+
"2e1424d4-f796-459a-8184-9c92662be6da"
7+
],
8+
"request_id": null
9+
},
310
"statusCode": 200
411
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"statusCode": 200,
3-
"body": "hello, dog!"
3+
"body": {
4+
"message": "hello, dog!",
5+
"request_id": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
6+
"event_record_ids": []
7+
}
48
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
{
22
"statusCode": 200,
3-
"body": "hello, dog!"
3+
"body": {
4+
"message": "hello, dog!",
5+
"request_id": null,
6+
"event_record_ids": [
7+
"95df01b4-ee98-5cb9-9903-4c221d41eb5e"
8+
]
9+
}
410
}
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
{
22
"statusCode": 200,
3-
"body": "hello, dog!"
3+
"body": {
4+
"message": "hello, dog!",
5+
"request_id": null,
6+
"event_record_ids": [
7+
"059f36b4-87a3-44ab-83d2-661975830a7d",
8+
"2e1424d4-f796-459a-8184-9c92662be6da"
9+
]
10+
}
411
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"statusCode": 200,
3-
"body": "hello, dog!"
3+
"body": {
4+
"message": "hello, dog!",
5+
"request_id": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
6+
"event_record_ids": []
7+
}
48
}

0 commit comments

Comments
 (0)