You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/core/logger.mdx
+25-7
Original file line number
Diff line number
Diff line change
@@ -222,21 +222,24 @@ If you ever forget to use `child` param, we will return an existing `Logger` wit
222
222
223
223
## Sampling debug logs
224
224
225
-
You can dynamically set a percentage of your logs to **DEBUG** level using `sample_rate`param or via env var`POWERTOOLS_LOGGER_SAMPLE_RATE`.
225
+
Sampling allows you to set your Logger Log Level as DEBUG based on a percentage of your concurrent/cold start invocations. You can set a sampling value of `0.0`to `1` (100%) using either `sample_rate`parameter or `POWERTOOLS_LOGGER_SAMPLE_RATE` env var.
226
226
227
-
Sampling calculation happens at the Logger class initialization. This means, when configured it, sampling it's more likely to happen during concurrent requests, or infrequent invocations as [new Lambda execution contexts are created](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-context.html), not reused.
227
+
This is useful when you want to troubleshoot an issue, say a sudden increase in concurrency, and you might not have enough information in your logs as Logger log level was understandably set as INFO.
228
+
229
+
Sampling calculation happens at the Logger class initialization. This means sampling will unlikely if you have a steady low number of invocations, depending on what you configured it.
228
230
229
231
<Notetype="info">
230
-
If you want this logic to happen on every invocation regardless whether Lambda reuses the execution environment or not, then create your Logger inside your Lambda handler.
232
+
If you want Logger to calculate sampling on every invocation, then please open a feature request.
"message": "Verifying whether order_id is present"
264
+
}
265
+
249
266
{
250
267
"timestamp": "2020-05-24 18:17:33,774",
251
268
"level": "INFO",
@@ -260,6 +277,7 @@ def handler(event, context):
260
277
"message": "Collecting payment"
261
278
}
262
279
```
280
+
263
281
</details>
264
282
265
283
@@ -305,7 +323,7 @@ This can be fixed by either ensuring both has the `service` value as `payment`,
305
323
306
324
You might want to continue to use the same date formatting style, or override `location` to display the `package.function_name:line_number` as you previously had.
307
325
308
-
Logger allows you to either change the format or suppress the following keys altogether at the initialization: `location`, `timestamp`, `level`, and `datefmt`
326
+
Logger allows you to either change the format or suppress the following keys altogether at the initialization: `location`, `timestamp`, `level`, `xray_trace_id`, and `datefmt`
Alternatively, you can also change the order of the following log record keys via the `log_record_order` parameter: `level`, `location`, `message`, and `timestamp`
338
+
Alternatively, you can also change the order of the following log record keys via the `log_record_order` parameter: `level`, `location`, `message`, `xray_trace_id`, and `timestamp`
0 commit comments