diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 66bf5fb52..93d859671 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -15,7 +15,7 @@ You can configure Powertools for AWS Lambda using environment variables. This is | **POWERTOOLS_SERVICE_NAME** | Set service name used for tracing namespace, metrics dimension and structured logging | All | `service_undefined` | | **POWERTOOLS_METRICS_NAMESPACE** | Set namespace used for metrics | [Metrics](features/metrics.md) | `default_namespace` | | **POWERTOOLS_METRICS_FUNCTION_NAME** | Function name used as dimension for the `ColdStart` metric | [Metrics](features/metrics.md) | [See docs](features/metrics.md#setting-function-name) | -| **POWERTOOLS_METRICS_ENABLED** | Explicitly disables emitting metrics to stdout | [Metrics](features/metrics.md) | `true` | +| **POWERTOOLS_METRICS_DISABLED** | Explicitly disables emitting metrics to stdout | [Metrics](features/metrics.md) | `false` | | **POWERTOOLS_TRACE_ENABLED** | Explicitly disables tracing | [Tracer](features/tracer.md) | `true` | | **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Capture Lambda or method return as metadata. | [Tracer](features/tracer.md) | `true` | | **POWERTOOLS_TRACER_CAPTURE_ERROR** | Capture Lambda or method exception as metadata. | [Tracer](features/tracer.md) | `true` | @@ -40,4 +40,4 @@ When `POWERTOOLS_DEV` is set to a truthy value (`1`, `true`), it'll have the fol | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Logger** | Increase JSON indentation to 4 and uses global `console` to emit logs to ease testing and local debugging when running functions locally. However, Amazon CloudWatch Logs view will degrade as each new line is treated as a new message | | **Tracer** | Disables tracing operations in non-Lambda environments. This already happens automatically in the Tracer utility | -| **Metrics** | Disables emitting metrics to stdout. Can be overridden by setting `POWERTOOLS_METRICS_ENABLED` to `true` | +| **Metrics** | Disables emitting metrics to stdout. Can be overridden by explicitly setting `POWERTOOLS_METRICS_DISABLED` to `false` | diff --git a/docs/features/metrics.md b/docs/features/metrics.md index 0954a7ec0..add53e6bb 100644 --- a/docs/features/metrics.md +++ b/docs/features/metrics.md @@ -71,7 +71,7 @@ These settings will be used across all metrics emitted: | **Service** | Optionally, sets **service** metric dimension across all metrics | `POWERTOOLS_SERVICE_NAME` | `service_undefined` | Any string | `serverlessAirline` | `serviceName` | | **Metric namespace** | Logical container where all metrics will be placed | `POWERTOOLS_METRICS_NAMESPACE` | `default_namespace` | Any string | `serverlessAirline` | `default_namespace` | | **Function Name** | Function name used as dimension for the `ColdStart` metric | `POWERTOOLS_METRICS_FUNCTION_NAME` | [See docs](#capturing-a-cold-start-invocation-as-metric) | Any string | `my-function-name` | `functionName` | -| **Enabled** | Whether to emit metrics to standard output or not | `POWERTOOLS_METRICS_ENABLED` | `true` | Boolean | `false` | | +| **Disabled** | Whether to disable the log of metrics to standard output or not | `POWERTOOLS_METRICS_DISABLED` | `false` | Boolean | `true` | | !!! tip Use your application name or main service as the metric namespace to easily group all metrics @@ -493,7 +493,7 @@ You can customize how Metrics logs warnings and debug messages to standard outpu When unit testing your code that uses the Metrics utility, you may want to silence the logs emitted by the utility. To do so, you can set the `POWERTOOLS_DEV` environment variable to `true`. This instructs the utility to not emit any logs to standard output. -If instead you want to spy on the logs emitted by the utility, you must set the `POWERTOOLS_DEV` environment variable to `true` in conjunction with the `POWERTOOLS_METRICS_ENABLED` environment variable also set to `true`. +If instead you want to spy on the logs emitted by the utility, you must set the `POWERTOOLS_DEV` environment variable to `true` in conjunction with the `POWERTOOLS_METRICS_DISABLED` environment variable set to `false`. When `POWERTOOLS_DEV` is enabled, Metrics uses the global `console` to emit metrics to standard out. This allows you to easily spy on the logs emitted and make assertions on them. diff --git a/examples/snippets/metrics/testingMetrics.ts b/examples/snippets/metrics/testingMetrics.ts index af2d4b796..dcf008fc0 100644 --- a/examples/snippets/metrics/testingMetrics.ts +++ b/examples/snippets/metrics/testingMetrics.ts @@ -2,7 +2,7 @@ import { describe, expect, it, vi } from 'vitest'; vi.hoisted(() => { process.env.POWERTOOLS_DEV = 'true'; - process.env.POWERTOOLS_METRICS_ENABLED = 'true'; + process.env.POWERTOOLS_METRICS_DISABLED = 'false'; }); describe('Metrics tests', () => {