diff --git a/docs/core/logger.md b/docs/core/logger.md index 30a43a5817c..6fc48e8898f 100644 --- a/docs/core/logger.md +++ b/docs/core/logger.md @@ -24,6 +24,8 @@ Logger requires two settings: | **Logging level** | Sets how verbose Logger should be (INFO, by default) | `LOG_LEVEL` | `level` | | **Service** | Sets **service** key that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `service` | +There are some [other environment variables](#environment-variables) which can be set to modify Logger's settings at a global scope. + ```yaml hl_lines="12-13" title="AWS Serverless Application Model (SAM) example" --8<-- "examples/logger/sam/template.yaml" ``` @@ -341,6 +343,18 @@ You can easily change the date format using one of the following parameters: --8<-- "examples/logger/src/date_formatting_output.json" ``` +### Environment variables + +The following environment variables are available to configure Logger at a global scope: + +| Setting | Description | Environment variable | Default | +|---------------------------|------------------------------------------------------------------------------|-----------------------------------------|---------| +| **Event Logging** | Whether to log the incoming event. | `POWERTOOLS_LOGGER_LOG_EVENT` | `false` | +| **Debug Sample Rate** | Sets the debug log sampling. | `POWERTOOLS_LOGGER_SAMPLE_RATE` | `0` | +| **Disable Deduplication** | Disables log deduplication filter protection to use Pytest Live Log feature. | `POWERTOOLS_LOG_DEDUPLICATION_DISABLED` | `false` | + +[`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. + ## Advanced ### Built-in Correlation ID expressions diff --git a/docs/core/metrics.md b/docs/core/metrics.md index 63ee307e789..2fd4cfc98d1 100644 --- a/docs/core/metrics.md +++ b/docs/core/metrics.md @@ -193,6 +193,16 @@ This has the advantage of keeping cold start metric separate from your applicati ???+ info 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. +### Environment variables + +The following environment variable is available to configure Metrics at a global scope: + +| Setting | Description | Environment variable | Default | +|--------------------|------------------------------------------------------------------------------|-----------------------------------------|---------| +| **Namespace Name** | Sets namespace used for metrics. | `POWERTOOLS_METRICS_NAMESPACE` | `None` | + +`POWERTOOLS_METRICS_NAMESPACE` is also available on a per-instance basis with the `namespace` parameter, which will consequently override the environment variable value. + ## Advanced ### Adding metadata @@ -319,7 +329,7 @@ That is why `Metrics` shares data across instances by default, as that covers 80 ## Testing your code -### Environment variables +### Setting environment variables ???+ tip Ignore this section, if: diff --git a/docs/core/tracer.md b/docs/core/tracer.md index 413434718db..f7163564e6b 100644 --- a/docs/core/tracer.md +++ b/docs/core/tracer.md @@ -103,6 +103,18 @@ You can trace asynchronous functions and generator functions (including context --8<-- "examples/tracer/src/capture_method_generators.py" ``` +### Environment variables + +The following environment variables are available to configure Tracer at a global scope: + +| Setting | Description | Environment variable | Default | +|-----------------------|--------------------------------------------------|--------------------------------------|---------| +| **Disable Tracing** | Explicitly disables all tracing. | `POWERTOOLS_TRACE_DISABLED` | `false` | +| **Response Capture** | Captures Lambda or method return as metadata. | `POWERTOOLS_TRACER_CAPTURE_RESPONSE` | `true` | +| **Exception Capture** | Captures Lambda or method exception as metadata. | `POWERTOOLS_TRACER_CAPTURE_ERROR` | `true` | + +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. + ## Advanced ### Patching modules diff --git a/docs/utilities/middleware_factory.md b/docs/utilities/middleware_factory.md index 6b0847ddb47..35e5453af65 100644 --- a/docs/utilities/middleware_factory.md +++ b/docs/utilities/middleware_factory.md @@ -68,6 +68,16 @@ You can also have your own keyword arguments after the mandatory arguments. --8<-- "examples/middleware_factory/src/getting_started_middleware_with_params_payload.json" ``` +### Environment variables + +The following environment variable is available to configure the middleware factory at a global scope: + +| Setting | Description | Environment variable | Default | +|----------------------|------------------------------------------------------------------------------|-----------------------------------------|---------| +| **Middleware Trace** | Creates sub-segment for each custom middleware. | `POWERTOOLS_TRACE_MIDDLEWARES` | `false` | + +You can also use [`POWERTOOLS_TRACE_MIDDLEWARES`](#tracing-middleware-execution) on a per-method basis, which will consequently override the environment variable value. + ## Advanced 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. diff --git a/docs/utilities/parameters.md b/docs/utilities/parameters.md index fa3241f43a8..d2d80230c77 100644 --- a/docs/utilities/parameters.md +++ b/docs/utilities/parameters.md @@ -107,6 +107,17 @@ The following will retrieve the latest version and store it in the cache. --8<-- "examples/parameters/src/getting_started_appconfig.py" ``` +### Environment variables + +The following environment variables are available to configure the parameter utility at a global scope: + +| Setting | Description | Environment variable | Default | +|-----------------------|--------------------------------------------------------------------------------|-------------------------------------|---------| +| **Max Age** | Adjusts for how long values are kept in cache (in seconds). | `POWERTOOLS_PARAMETERS_MAX_AGE` | `5` | +| **Debug Sample Rate** | Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store. | `POWERTOOLS_PARAMETERS_SSM_DECRYPT` | `false` | + +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. + ## Advanced ### Adjusting cache TTL