Skip to content

Commit 5ce443b

Browse files
authored
redact dd-api-key (#307)
* redact dd-api-key * fix flaky test_cold_start
1 parent 0630e09 commit 5ce443b

8 files changed

+67
-64
lines changed

scripts/run_integration_tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,14 +187,15 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do
187187
sed '/^$/d' |
188188
# Normalize Lambda runtime REPORT logs
189189
sed -E 's/(RequestId|TraceId|SegmentId|Duration|init|Memory Used|"e"): [a-z0-9\.\-]+/\1: XXXX/g' |
190+
sed -E 's/(python:3.[0-9]+\.v)[0-9]+/\1X/g' |
190191
# Normalize HTTP headers
191192
sed -E "s/(x-datadog-parent-id:|x-datadog-trace-id:|Content-Length:)[0-9]+/\1XXXX/g" |
192193
# Remove Account ID
193194
sed -E "s/(account_id:)[0-9]+/\1XXXX/g" |
194195
# Normalize timestamps in datapoints POSTed to DD
195196
sed -E 's/"points": \[\[[0-9\.]+,/"points": \[\[XXXX,/g' |
196197
# Strip API key from logged requests
197-
sed -E "s/(api_key=|'api_key': ')[a-z0-9\.\-]+/\1XXXX/g" |
198+
sed -E "s/(api_key=|'api_key': '|DD-API-KEY:)[a-z0-9\.\-]+/\1XXXX/g" |
198199
# Normalize package version so that these snapshots aren't broken on version bumps
199200
sed -E "s/(dd_lambda_layer:datadog-python[0-9]+_)[0-9]+\.[0-9]+\.[0-9]+/\1X\.X\.X/g" |
200201
sed -E "s/(datadog_lambda:v)([0-9]+\.[0-9]+\.[0-9])/\1XX/g" |

tests/integration/snapshots/logs/async-metrics_python37.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INIT_START Runtime Version: python:3.7.v22 Runtime Version ARN: arn:aws:lambda:eu-west-1:XXXX:eu-west-1
1+
INIT_START Runtime Version: python:3.7.vX Runtime Version ARN: arn:aws:lambda:eu-west-1:XXXX:eu-west-1
22
START
33
{
44
"m": "aws.lambda.enhanced.invocations",

tests/integration/snapshots/logs/async-metrics_python38.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INIT_START Runtime Version: python:3.8.v15 Runtime Version ARN: arn:aws:lambda:eu-west-1:XXXX:eu-west-1
1+
INIT_START Runtime Version: python:3.8.vX Runtime Version ARN: arn:aws:lambda:eu-west-1:XXXX:eu-west-1
22
START
33
{
44
"m": "aws.lambda.enhanced.invocations",

tests/integration/snapshots/logs/async-metrics_python39.log

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INIT_START Runtime Version: python:3.9.v16 Runtime Version ARN: arn:aws:lambda:eu-west-1:XXXX:eu-west-1
1+
INIT_START Runtime Version: python:3.9.vX Runtime Version ARN: arn:aws:lambda:eu-west-1:XXXX:eu-west-1
22
START
33
{
44
"m": "aws.lambda.enhanced.invocations",

tests/integration/snapshots/logs/sync-metrics_python37.log

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

tests/integration/snapshots/logs/sync-metrics_python38.log

Lines changed: 20 additions & 20 deletions
Large diffs are not rendered by default.

tests/integration/snapshots/logs/sync-metrics_python39.log

Lines changed: 19 additions & 19 deletions
Large diffs are not rendered by default.

tests/test_cold_start.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ def find_spec(*args, **kwargs):
6666
import dummy_module
6767
except Exception as e:
6868
self.assertEqual(str(e), "Module failed to load")
69-
self.assertEqual(len(cold_start.root_nodes), 1)
69+
meta_path.pop(0) # clean up first before checking test results
70+
self.assertEqual(
71+
len(cold_start.root_nodes), 1
72+
) # push_node should have pushed the node
7073
self.assertEqual(cold_start.root_nodes[0].module_name, mock_module_spec.name)
71-
meta_path.pop(0)
7274

7375

7476
class TestColdStartTracer(unittest.TestCase):

0 commit comments

Comments
 (0)