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/core/metrics.md
+24-6
Original file line number
Diff line number
Diff line change
@@ -34,21 +34,20 @@ If you're new to Amazon CloudWatch, there are five terminologies you must be awa
34
34
???+ tip
35
35
All examples shared in this documentation are available within the [project repository](https://github.com/aws-powertools/powertools-lambda-python/tree/develop/examples){target="_blank"}.
36
36
37
-
Metric has three global settings that will be used across all metrics emitted:
37
+
Metric has two global settings that will be used across all metrics emitted:
`POWERTOOLS_METRICS_DISABLED` will not disable default metrics created by AWS services.
47
46
48
47
???+ tip
49
48
Use your application or main service as the metric namespace to easily group all metrics.
50
49
51
-
```yaml hl_lines="13" title="AWS Serverless Application Model (SAM) example"
50
+
```yaml hl_lines="12-14" title="AWS Serverless Application Model (SAM) example"
52
51
--8<-- "examples/metrics/sam/template.yaml"
53
52
```
54
53
@@ -214,13 +213,32 @@ This has the advantage of keeping cold start metric separate from your applicati
214
213
???+ info
215
214
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.
216
215
216
+
#### Customizing function name for cold start metrics
217
+
218
+
When emitting cold start metrics, the `function_name` dimension defaults to `context.function_name`. If you want to change the value you can set the `function_name` parameter in the metrics constructor, or define the environment variable `POWERTOOLS_METRICS_FUNCTION_NAME`.
219
+
220
+
The priority of the `function_name` dimension value is defined as:
|**Namespace Name**| Sets **namespace** used for metrics. |`POWERTOOLS_METRICS_NAMESPACE`|`None`|
239
+
|**Service**| Sets **service** metric dimension across all metrics e.g. `payment`|`POWERTOOLS_SERVICE_NAME`|`None`|
240
+
|**Function Name**| Function name used as dimension for the **ColdStart** metric. |`POWERTOOLS_METRICS_FUNCTION_NAME`|`None`|
241
+
|**Disable Powertools Metrics**|**Disables** all metrics emitted by Powertools. |`POWERTOOLS_METRICS_DISABLED`|`None`|
224
242
225
243
`POWERTOOLS_METRICS_NAMESPACE` is also available on a per-instance basis with the `namespace` parameter, which will consequently override the environment variable value.
|__POWERTOOLS_TRACER_CAPTURE_RESPONSE__| Captures Lambda or method return as metadata. |[Tracing](./core/tracer.md){target="_blank"} |`true`|
412
-
|__POWERTOOLS_TRACER_CAPTURE_ERROR__| Captures Lambda or method exception as metadata. |[Tracing](./core/tracer.md){target="_blank"} |`true`|
413
-
|__POWERTOOLS_TRACE_MIDDLEWARES__| Creates sub-segment for each custom middleware |[Middleware factory](./utilities/middleware_factory.md){target="_blank"} |`false`|
|__POWERTOOLS_LOG_DEDUPLICATION_DISABLED__| Disables log deduplication filter protection to use Pytest Live Log feature |[Logging](./core/logger.md){target="_blank"} |`false`|
417
-
|__POWERTOOLS_PARAMETERS_MAX_AGE__| Adjust how long values are kept in cache (in seconds) |[Parameters](./utilities/parameters.md#adjusting-cache-ttl){target="_blank"} |`5`|
418
-
|__POWERTOOLS_PARAMETERS_SSM_DECRYPT__| Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store |[Parameters](./utilities/parameters.md#ssmprovider){target="_blank"} |`false`|
419
-
|__POWERTOOLS_DEV__| Increases verbosity across utilities | Multiple; see [POWERTOOLS_DEV effect below](#optimizing-for-non-production-environments)|`false`|
|**POWERTOOLS_SERVICE_NAME**| Sets service name used for tracing namespace, metrics dimension and structured logging | All |`"service_undefined"`|
409
+
|**POWERTOOLS_METRICS_NAMESPACE**| Sets namespace used for metrics |[Metrics](./core/metrics.md){target="_blank"} |`None`|
410
+
|**POWERTOOLS_METRICS_FUNCTION_NAME**| Function name used as dimension for the **ColdStart** metric metrics |[Metrics](./core/metrics.md){target="_blank"} |`None`|
411
+
|**POWERTOOLS_METRICS_DISABLED**|**Disables** all metrics emitted by Powertools metrics |[Metrics](./core/metrics.md){target="_blank"} |`None`|
|**POWERTOOLS_TRACER_CAPTURE_RESPONSE**| Captures Lambda or method return as metadata. |[Tracing](./core/tracer.md){target="_blank"} |`true`|
414
+
|**POWERTOOLS_TRACER_CAPTURE_ERROR**| Captures Lambda or method exception as metadata. |[Tracing](./core/tracer.md){target="_blank"} |`true`|
415
+
|**POWERTOOLS_TRACE_MIDDLEWARES**| Creates sub-segment for each custom middleware |[Middleware factory](./utilities/middleware_factory.md){target="_blank"} |`false`|
|**POWERTOOLS_LOG_DEDUPLICATION_DISABLED**| Disables log deduplication filter protection to use Pytest Live Log feature |[Logging](./core/logger.md){target="_blank"} |`false`|
419
+
|**POWERTOOLS_PARAMETERS_MAX_AGE**| Adjust how long values are kept in cache (in seconds) |[Parameters](./utilities/parameters.md#adjusting-cache-ttl){target="_blank"} |`5`|
420
+
|**POWERTOOLS_PARAMETERS_SSM_DECRYPT**| Sets whether to decrypt or not values retrieved from AWS SSM Parameters Store |[Parameters](./utilities/parameters.md#ssmprovider){target="_blank"} |`false`|
421
+
|**POWERTOOLS_DEV**| Increases verbosity across utilities | Multiple; see [POWERTOOLS_DEV effect below](#optimizing-for-non-production-environments)|`false`|
0 commit comments