Skip to content

Commit 9a2ddc5

Browse files
committed
feat(logger): add log sampling
1 parent 951a69e commit 9a2ddc5

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Lambda Powertools
22

3-
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fawslabs%2Faws-lambda-powertools%2Fbadge%3Fref%3Ddevelop&style=flat)](https://actions-badge.atrox.dev/awslabs/aws-lambda-powertools/goto?ref=develop) ![PackageStatus](https://img.shields.io/static/v1?label=status&message=beta&color=blueviolet?style=flat-square) ![PythonSupport](https://img.shields.io/static/v1?label=python&message=3.6%20|%203.7&color=blue?style=flat-square&logo=python)
3+
![PackageStatus](https://img.shields.io/static/v1?label=status&message=beta&color=blueviolet?style=flat-square) ![PythonSupport](https://img.shields.io/static/v1?label=python&message=3.6%20|%203.7&color=blue?style=flat-square&logo=python)
44

55
A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray, structured logging and creating custom metrics asynchronously easier - Currently available for Python only and compatible with Python >=3.6.
66

@@ -22,6 +22,8 @@ A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray,
2222
* Optionally log Lambda request when instructed (disabled by default)
2323
- Enable via `POWERTOOLS_LOGGER_LOG_EVENT="true"` or explicitly via decorator param
2424
* Logs canonical custom metric line to logs that can be consumed asynchronously
25+
* Log sampling enables DEBUG log level for a percentage of requests (disabled by default)
26+
- Enable via `POWERTOOLS_LOGGER_SAMPLE_RATE=0.1`, ranges from 0 to 1, where 0.1 is 10% and 1 is 100%
2527

2628
**Environment variables** used across suite of utilities
2729

@@ -30,6 +32,7 @@ Environment variable | Description | Default | Utility
3032
POWERTOOLS_SERVICE_NAME | Sets service name used for tracing namespace, metrics dimensions and structured logging | "service_undefined" | all
3133
POWERTOOLS_TRACE_DISABLED | Disables tracing | "false" | tracing
3234
POWERTOOLS_LOGGER_LOG_EVENT | Logs incoming event | "false" | logging
35+
POWERTOOLS_LOGGER_SAMPLE_RATE | Debug log sampling | 0 | logging
3336
LOG_LEVEL | Sets logging level | "INFO" | logging
3437

3538
## Usage
@@ -85,6 +88,7 @@ Globals:
8588
Environment:
8689
Variables:
8790
POWERTOOLS_SERVICE_NAME: "payment"
91+
POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1 # enable debug logging for 1% of requests, 0% by default
8892
LOG_LEVEL: "INFO"
8993
```
9094
@@ -185,9 +189,7 @@ This library may change its API/methods or environment variables as it receives
185189

186190
## TODO
187191

188-
* [ ] Enable CI
189192
* [ ] Add an example code using powertools
190-
* [ ] Automate release and version bumping in CI
191193

192194
## Credits
193195

python/HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# HISTORY
22

3+
## February 20th, 2020
4+
5+
**0.4.0**
6+
7+
* Introduces log sampling for debug - Thanks to [Danilo's contribution](https://github.com/awslabs/aws-lambda-powertools/pull/7)
8+
39
## November 15th, 2019
410

511
* Public beta release

python/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ A suite of utilities for AWS Lambda Functions that makes tracing with AWS X-Ray,
2222
* Optionally log Lambda request when instructed (disabled by default)
2323
- Enable via `POWERTOOLS_LOGGER_LOG_EVENT="true"` or explicitly via decorator param
2424
* Logs canonical custom metric line to logs that can be consumed asynchronously
25+
* Log sampling enables DEBUG log level for a percentage of requests (disabled by default)
26+
- Enable via `POWERTOOLS_LOGGER_SAMPLE_RATE=0.1`, ranges from 0 to 1, where 0.1 is 10% and 1 is 100%
2527

2628
**Environment variables** used across suite of utilities
2729

@@ -30,6 +32,7 @@ Environment variable | Description | Default | Utility
3032
POWERTOOLS_SERVICE_NAME | Sets service name used for tracing namespace, metrics dimensions and structured logging | "service_undefined" | all
3133
POWERTOOLS_TRACE_DISABLED | Disables tracing | "false" | tracing
3234
POWERTOOLS_LOGGER_LOG_EVENT | Logs incoming event | "false" | logging
35+
POWERTOOLS_LOGGER_SAMPLE_RATE | Debug log sampling | 0 | logging
3336
LOG_LEVEL | Sets logging level | "INFO" | logging
3437

3538
## Usage
@@ -85,6 +88,7 @@ Globals:
8588
Environment:
8689
Variables:
8790
POWERTOOLS_SERVICE_NAME: "payment"
91+
POWERTOOLS_LOGGER_SAMPLE_RATE: 0.1 # enable debug logging for 1% of requests, 0% by default
8892
LOG_LEVEL: "INFO"
8993
```
9094
@@ -185,7 +189,6 @@ This library may change its API/methods or environment variables as it receives
185189

186190
## TODO
187191

188-
* [ ] Enable CI
189192
* [ ] Add an example code using powertools
190193

191194
## Credits

0 commit comments

Comments
 (0)