Skip to content

Commit e800128

Browse files
chore(docs): include the environment variables section in the utilities documentation (#2925)
Co-authored-by: Leandro Damascena <[email protected]>
1 parent 0e61026 commit e800128

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

docs/core/logger.md

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Logger requires two settings:
2424
| **Logging level** | Sets how verbose Logger should be (INFO, by default) | `LOG_LEVEL` | `level` |
2525
| **Service** | Sets **service** key that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `service` |
2626

27+
There are some [other environment variables](#environment-variables) which can be set to modify Logger's settings at a global scope.
28+
2729
```yaml hl_lines="12-13" title="AWS Serverless Application Model (SAM) example"
2830
--8<-- "examples/logger/sam/template.yaml"
2931
```
@@ -341,6 +343,18 @@ You can easily change the date format using one of the following parameters:
341343
--8<-- "examples/logger/src/date_formatting_output.json"
342344
```
343345

346+
### Environment variables
347+
348+
The following environment variables are available to configure Logger at a global scope:
349+
350+
| Setting | Description | Environment variable | Default |
351+
|---------------------------|------------------------------------------------------------------------------|-----------------------------------------|---------|
352+
| **Event Logging** | Whether to log the incoming event. | `POWERTOOLS_LOGGER_LOG_EVENT` | `false` |
353+
| **Debug Sample Rate** | Sets the debug log sampling. | `POWERTOOLS_LOGGER_SAMPLE_RATE` | `0` |
354+
| **Disable Deduplication** | Disables log deduplication filter protection to use Pytest Live Log feature. | `POWERTOOLS_LOG_DEDUPLICATION_DISABLED` | `false` |
355+
356+
[`POWERTOOLS_LOGGER_LOG_EVENT`](#logging-incoming-event) can also be set on a per-method basis, and [`POWERTOOLS_LOGGER_SAMPLE_RATE`](#sampling-debug-logs) on a per-instance basis. These parameter values will override the environment variable value.
357+
344358
## Advanced
345359

346360
### Built-in Correlation ID expressions

docs/core/metrics.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ This has the advantage of keeping cold start metric separate from your applicati
193193
???+ info
194194
We do not emit 0 as a value for ColdStart metric for cost reasons. [Let us know](https://github.com/aws-powertools/powertools-lambda-python/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=){target="_blank"} if you'd prefer a flag to override it.
195195

196+
### Environment variables
197+
198+
The following environment variable is available to configure Metrics at a global scope:
199+
200+
| Setting | Description | Environment variable | Default |
201+
|--------------------|------------------------------------------------------------------------------|-----------------------------------------|---------|
202+
| **Namespace Name** | Sets namespace used for metrics. | `POWERTOOLS_METRICS_NAMESPACE` | `None` |
203+
204+
`POWERTOOLS_METRICS_NAMESPACE` is also available on a per-instance basis with the `namespace` parameter, which will consequently override the environment variable value.
205+
196206
## Advanced
197207

198208
### Adding metadata
@@ -319,7 +329,7 @@ That is why `Metrics` shares data across instances by default, as that covers 80
319329

320330
## Testing your code
321331

322-
### Environment variables
332+
### Setting environment variables
323333

324334
???+ tip
325335
Ignore this section, if:

docs/core/tracer.md

+12
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ You can trace asynchronous functions and generator functions (including context
103103
--8<-- "examples/tracer/src/capture_method_generators.py"
104104
```
105105

106+
### Environment variables
107+
108+
The following environment variables are available to configure Tracer at a global scope:
109+
110+
| Setting | Description | Environment variable | Default |
111+
|-----------------------|--------------------------------------------------|--------------------------------------|---------|
112+
| **Disable Tracing** | Explicitly disables all tracing. | `POWERTOOLS_TRACE_DISABLED` | `false` |
113+
| **Response Capture** | Captures Lambda or method return as metadata. | `POWERTOOLS_TRACER_CAPTURE_RESPONSE` | `true` |
114+
| **Exception Capture** | Captures Lambda or method exception as metadata. | `POWERTOOLS_TRACER_CAPTURE_ERROR` | `true` |
115+
116+
Both [`POWERTOOLS_TRACER_CAPTURE_RESPONSE`](#disabling-response-auto-capture) and [`POWERTOOLS_TRACER_CAPTURE_ERROR`](#disabling-exception-auto-capture) can be set on a per-method basis, consequently overriding the environment variable value.
117+
106118
## Advanced
107119

108120
### Patching modules

docs/utilities/middleware_factory.md

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ You can also have your own keyword arguments after the mandatory arguments.
6868
--8<-- "examples/middleware_factory/src/getting_started_middleware_with_params_payload.json"
6969
```
7070

71+
### Environment variables
72+
73+
The following environment variable is available to configure the middleware factory at a global scope:
74+
75+
| Setting | Description | Environment variable | Default |
76+
|----------------------|------------------------------------------------------------------------------|-----------------------------------------|---------|
77+
| **Middleware Trace** | Creates sub-segment for each custom middleware. | `POWERTOOLS_TRACE_MIDDLEWARES` | `false` |
78+
79+
You can also use [`POWERTOOLS_TRACE_MIDDLEWARES`](#tracing-middleware-execution) on a per-method basis, which will consequently override the environment variable value.
80+
7181
## Advanced
7282

7383
For advanced use cases, you can instantiate [Tracer](../core/tracer.md){target="_blank"} inside your middleware, and add annotations as well as metadata for additional operational insights.

docs/utilities/parameters.md

+11
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,17 @@ The following will retrieve the latest version and store it in the cache.
107107
--8<-- "examples/parameters/src/getting_started_appconfig.py"
108108
```
109109

110+
### Environment variables
111+
112+
The following environment variables are available to configure the parameter utility at a global scope:
113+
114+
| Setting | Description | Environment variable | Default |
115+
|-----------------------|--------------------------------------------------------------------------------|-------------------------------------|---------|
116+
| **Max Age** | Adjusts for how long values are kept in cache (in seconds). | `POWERTOOLS_PARAMETERS_MAX_AGE` | `5` |
117+
| **Debug Sample Rate** | Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store. | `POWERTOOLS_PARAMETERS_SSM_DECRYPT` | `false` |
118+
119+
You can also use [`POWERTOOLS_PARAMETERS_MAX_AGE`](#adjusting-cache-ttl) through the `max_age` parameter and [`POWERTOOLS_PARAMETERS_SSM_DECRYPT`](#ssmprovider) through the `decrypt` parameter to override the environment variable values.
120+
110121
## Advanced
111122

112123
### Adjusting cache TTL

0 commit comments

Comments
 (0)