Commit bac841c
authored
fix: Fix log processing rule on orphan log (#912)
# Problem
When a user follows [our
doc](https://docs.datadoghq.com/serverless/aws_lambda/logs/?tab=serverlessframework#filter-or-scrub-information-from-logs)
to set the env var: `DD_LOGS_CONFIG_PROCESSING_RULES `: `[{"type":
"exclude_at_match", "name": "exclude_start_and_end_logs", "pattern":
"(START|END|REPORT) RequestId"}]`, we not only excludes `START`, `END`
and `REPORT` logs, but some other logs as well, such as (1) extension
log and (2) error log from the Lambda handler. As a result, errors can
be left unobserved.
# Bug
This is because we first apply the log processing rules to the log we
receive from telemetry API, to decide whether to send it to Datadog,
then use the same result for "orphan log", which may include extension
log and user error log.
# This PR
For each orphan log, evaluate log processing rules again, instead of
reusing the existing result.
# Testing
## Setup
- Lambda runtime: Node 22
- Handler:
```
const region = process.env["NO_REGION"];
if (!region) {
throw new Error("NO_REGION environment variable not set");
}
export const handler = async (event) => {
const response = {
statusCode: 200,
body: JSON.stringify('Hello from Lambda!'),
};
return response;
};
```
- Env var: `DD_LOGS_CONFIG_PROCESSING_RULES `: `[{"type":
"exclude_at_match", "name": "exclude_start_and_end_logs", "pattern":
"(START|END|REPORT) RequestId"}]`
## Result before:
No log showed up in Datadog's Log Explorer or Live Tail
## Result after:
Custom error log and extension log showed up.
<img width="1239" height="552" alt="image"
src="https://github.com/user-attachments/assets/e3991979-b72d-44a4-b819-c36c7d33aa7c"
/>
# Notes
Thanks @duncanista @astuyve @litianningdatadog for debugging and
discussion.
Jira: https://datadoghq.atlassian.net/browse/SLES-24691 parent ebf4d41 commit bac841c
1 file changed
+121
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
324 | 324 | | |
325 | 325 | | |
326 | 326 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
338 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
339 | 344 | | |
340 | 345 | | |
341 | | - | |
| 346 | + | |
| 347 | + | |
342 | 348 | | |
343 | 349 | | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
| 350 | + | |
350 | 351 | | |
351 | 352 | | |
352 | 353 | | |
| |||
1085 | 1086 | | |
1086 | 1087 | | |
1087 | 1088 | | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
1088 | 1191 | | |
0 commit comments