|
2 | 2 |
|
3 | 3 | # Usage: |
4 | 4 | # To check if new changes to the layer cause changes to any snapshots: |
5 | | -# BUILD_LAYERS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests |
| 5 | +# BUILD_LAYERS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests |
6 | 6 | # To regenerate snapshots: |
7 | | -# UPDATE_SNAPSHOTS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests |
| 7 | +# UPDATE_SNAPSHOTS=true DD_API_KEY=XXXX aws-vault exec sandbox-account-admin -- ./scripts/run_integration_tests |
8 | 8 |
|
9 | 9 | set -e |
10 | 10 |
|
@@ -85,22 +85,22 @@ for handler_name in "${LAMBDA_HANDLERS[@]}"; do |
85 | 85 | function_snapshot_path="./snapshots/$function_name.logs" |
86 | 86 |
|
87 | 87 | # Fetch logs with serverless cli |
88 | | - logs=$(serverless logs -f $function_name --startTime $script_start_time) |
89 | | - |
90 | | - # Filter serverless cli errors |
91 | | - logs=$(echo "$logs" | sed '/Serverless: Recoverable error occurred/d') |
| 88 | + raw_logs=$(serverless logs -f $function_name --startTime $script_start_time) |
92 | 89 |
|
93 | 90 | # Replace invocation-specific data like timestamps and IDs with XXXX to normalize logs across executions |
94 | | - # Normalize Lambda runtime report logs |
95 | | - logs=$(echo "$logs" | sed -E 's/(RequestId|TraceId|SegmentId|Duration|Memory Used|"e"): [a-z0-9\.\-]+/\1: XXXX/g') |
96 | | - # Normalize DD APM headers |
97 | | - logs=$(echo "$logs" | sed -E "s/(x-datadog-parent-id:|x-datadog-trace-id:)[0-9]+/\1XXXX/g") |
98 | | - # Normalize timestamps in datapoints POSTed to DD |
99 | | - logs=$(echo "$logs" | sed -E 's/"points": \[\[[0-9\.]+,/"points": \[\[XXXX,/g') |
100 | | - # # Normalize invocation IDs used in requests to the Lambda runtime |
101 | | - # logs=$(echo "$logs" | sed -E 's/\/2018-06-01\/runtime\/invocation\/[a-z0-9-]+/\/2018-06-01\/runtime\/invocation\/XXXX/g') |
102 | | - # Strip API key from logged requests |
103 | | - logs=$(echo "$logs" | sed -E "s/(api_key=|'api_key': ')[a-z0-9\.\-]+/\1XXXX/g") |
| 91 | + logs=$( |
| 92 | + echo "$raw_logs" | |
| 93 | + # Filter serverless cli errors |
| 94 | + sed '/Serverless: Recoverable error occurred/d' | |
| 95 | + # Normalize Lambda runtime report logs |
| 96 | + sed -E 's/(RequestId|TraceId|SegmentId|Duration|Memory Used|"e"): [a-z0-9\.\-]+/\1: XXXX/g' | |
| 97 | + # Normalize DD APM headers |
| 98 | + sed -E "s/(x-datadog-parent-id:|x-datadog-trace-id:)[0-9]+/\1XXXX/g" | |
| 99 | + # Normalize timestamps in datapoints POSTed to DD |
| 100 | + sed -E 's/"points": \[\[[0-9\.]+,/"points": \[\[XXXX,/g' | |
| 101 | + # Strip API key from logged requests |
| 102 | + sed -E "s/(api_key=|'api_key': ')[a-z0-9\.\-]+/\1XXXX/g" |
| 103 | + ) |
104 | 104 |
|
105 | 105 | if [ -n "$UPDATE_SNAPSHOTS" ] || [ ! -f $function_snapshot_path ]; then |
106 | 106 | # If $UPDATE_SNAPSHOTS is set to true write the new logs over the current snapshot |
|
0 commit comments