Skip to content

Commit 050c22d

Browse files
authored
[Integration test] Add support for DD_TAGS and DD_EXTRA_TAGS (#6)
add integration tests for : DD_TAGS + DD_EXTRA_TAGS
1 parent d786715 commit 050c22d

File tree

6 files changed

+35
-21
lines changed

6 files changed

+35
-21
lines changed

.github/workflows/integration_tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ name: build
22

33
on:
44
schedule:
5-
- cron: "0 12 * * *" #every day at midday
5+
- cron: "0 12 * * *" #every day at midday (UTC)
6+
push:
7+
paths:
8+
- 'integration_tests/**'
69

710
jobs:
811

integration_tests/recorder-extension/src/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ async function next(extensionId) {
8787
app.post('/v1/input', async (req, res) => {
8888
if(JSON.stringify(req.body) !== '{}') { // to avoid printing empty logs due to the connectivity test
8989
for(let i = 0; i < req.body.length; ++i) {
90+
//sort tags to avoid flaky tests
91+
const originalTags = req.body[i].ddtags;
92+
const sortedTags = originalTags.split(",");
93+
sortedTags.sort();
94+
// reset tags once sorted
95+
req.body[i].ddtags = sortedTags.join(",")
9096
const logString = JSON.stringify(req.body[i]);
91-
if(logString.indexOf("[sketch]") === -1 && logString.indexOf("[log]") === -1) { // avoid inception
97+
if(logString.indexOf("[sketch]") === -1 && logString.indexOf("[log]") === -1) { // if we log an unwanted log, it will be availble in the next log api payload -> infinite loop
98+
const tags = logString
9299
console.log("[log]", logString);
93100
}
94101
}

integration_tests/run.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ for function_name in "${all_functions[@]}"; do
106106
echo "$raw_logs" | \
107107
grep "\[log\]" | \
108108
perl -p -e "s/(timestamp\":)[0-9]{13}/\1XXX/g" | \
109-
perl -p -e "s/(ddtags\":\")[a-zA-Z0-9\:\-,_]+/\1XXX/g" | \
110109
perl -p -e "s/(\"REPORT |START |END |HTTP ).*/\1XXX\"}}/g" | \
111110
perl -p -e "s/(request_id\":\")[a-zA-Z0-9\-,]+/\1XXX/g"| \
112111
perl -p -e "s/$stage/XXXXXX/g" | \

integration_tests/serverless.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ functions:
4646
- arn:aws:lambda:${self:provider.region}:464622532012:layer:Datadog-Node14-x:${env:NODE_LAYER_VERSION}
4747
- {Ref: RecorderExtensionLambdaLayer}
4848
- {Ref: DatadogExtensionIntegrationTestLambdaLayer}
49+
environment:
50+
DD_TAGS: tagA:valueA tagB:valueB
51+
DD_EXTRA_TAGS: tagC:valueC tagD:valueD
4952

5053
noEnhancedMetricTest:
5154
name: integration-tests-lambda-extension-${sls:stage}-noEnhancedMetricTest
@@ -82,3 +85,5 @@ functions:
8285
DD_LOGS_ENABLED: true
8386
DD_SERVERLESS_LOGS_ENABLED: true
8487
DD_LOGS_INJECTION: true
88+
DD_TAGS: tagA:valueA tagB:valueB
89+
DD_EXTRA_TAGS: tagC:valueC tagD:valueD
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
[sketch] {"metric":"aws.lambda.enhanced.billed_duration","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
2-
[sketch] {"metric":"aws.lambda.enhanced.duration","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
3-
[sketch] {"metric":"aws.lambda.enhanced.estimated_cost","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
4-
[sketch] {"metric":"aws.lambda.enhanced.init_duration","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
5-
[sketch] {"metric":"aws.lambda.enhanced.invocations","tags":["account_id:601427279990","aws_account:601427279990","cold_start:false","datadog_lambda:vX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","memorysize:1024","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","runtime:nodejs12.x"],"dogsketches":[{"ts":"XXX","cnt":"1","min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
6-
[sketch] {"metric":"aws.lambda.enhanced.invocations","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","datadog_lambda:vX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","memorysize:1024","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","runtime:nodejs12.x"],"dogsketches":[{"ts":"XXX","cnt":"1","min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
7-
[sketch] {"metric":"aws.lambda.enhanced.max_memory_used","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
8-
[sketch] {"metric":"aws.lambda.enhanced.memorysize","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
9-
[sketch] {"metric":"serverless.lambda-extension.integration-test.count","tags":["account_id:601427279990","aws_account:601427279990","dd_lambda_layer:datadog-nodevX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","k":[XXX],"n":[1]}]}
10-
[sketch] {"metric":"serverless.lambda-extension.integration-test.count","tags":["account_id:601427279990","aws_account:601427279990","dd_lambda_layer:datadog-nodevX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest"],"dogsketches":[{"ts":"XXX","cnt":"1","min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
1+
[sketch] {"metric":"aws.lambda.enhanced.billed_duration","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
2+
[sketch] {"metric":"aws.lambda.enhanced.duration","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
3+
[sketch] {"metric":"aws.lambda.enhanced.estimated_cost","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
4+
[sketch] {"metric":"aws.lambda.enhanced.init_duration","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
5+
[sketch] {"metric":"aws.lambda.enhanced.invocations","tags":["account_id:601427279990","aws_account:601427279990","cold_start:false","datadog_lambda:vX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","memorysize:1024","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","runtime:nodejs12.x","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
6+
[sketch] {"metric":"aws.lambda.enhanced.invocations","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","datadog_lambda:vX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","memorysize:1024","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedMetricTest","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","runtime:nodejs12.x","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}
7+
[sketch] {"metric":"aws.lambda.enhanced.max_memory_used","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
8+
[sketch] {"metric":"aws.lambda.enhanced.memorysize","tags":["account_id:601427279990","aws_account:601427279990","cold_start:true","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":XXX,"max":XXX,"avg":XXX,"sum":XXX,"k":[XXX],"n":[1]}]}
9+
[sketch] {"metric":"serverless.lambda-extension.integration-test.count","tags":["account_id:601427279990","aws_account:601427279990","dd_lambda_layer:datadog-nodevX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","k":[XXX],"n":[1]}]}
10+
[sketch] {"metric":"serverless.lambda-extension.integration-test.count","tags":["account_id:601427279990","aws_account:601427279990","dd_lambda_layer:datadog-nodevX.X.X","function_arn:arn:aws:lambda:sa-east-1:601427279990:function:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","functionname:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","region:sa-east-1","resource:integration-tests-lambda-extension-XXXXXX-enhancedmetrictest","taga:valuea","tagb:valueb","tagc:valuec","tagd:valued"],"dogsketches":[{"ts":"XXX","cnt":"1","min":1,"max":1,"avg":1,"sum":1,"k":[XXX],"n":[1]}]}

0 commit comments

Comments
 (0)