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
|**Service**| Optionally, sets **service** metric dimension across all metrics |`POWERTOOLS_SERVICE_NAME`|`service_undefined`| Any string |`serverlessAirline`|`serviceName`|
72
-
|**Metric namespace**| Logical container where all metrics will be placed |`POWERTOOLS_METRICS_NAMESPACE`|`default_namespace`| Any string |`serverlessAirline`|`default_namespace`|
73
-
|**Enabled**| Whether to emit metrics to standard output or not |`POWERTOOLS_METRICS_ENABLED`|`true`| Boolean |`false`||
|**Service**| Optionally, sets **service** metric dimension across all metrics |`POWERTOOLS_SERVICE_NAME`|`service_undefined`| Any string |`serverlessAirline`|`serviceName`|
72
+
|**Metric namespace**| Logical container where all metrics will be placed |`POWERTOOLS_METRICS_NAMESPACE`|`default_namespace`| Any string |`serverlessAirline`|`default_namespace`|
73
+
|**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`|
74
+
|**Enabled**| Whether to emit metrics to standard output or not |`POWERTOOLS_METRICS_ENABLED`|`true`| Boolean |`false`||
74
75
75
76
!!! tip
76
77
Use your application name or main service as the metric namespace to easily group all metrics
@@ -87,7 +88,7 @@ The `Metrics` utility is instantiated outside of the Lambda handler. In doing th
87
88
88
89
=== "template.yml"
89
90
90
-
```yaml hl_lines="9 10"
91
+
```yaml hl_lines="8-10"
91
92
Resources:
92
93
HelloWorldFunction:
93
94
Type: AWS::Serverless::Function
@@ -97,6 +98,7 @@ The `Metrics` utility is instantiated outside of the Lambda handler. In doing th
You can initialize Metrics anywhere in your code - It'll keep track of your aggregate metrics in memory.
@@ -184,7 +186,7 @@ You can call `addMetric()` with the same name multiple times. The values will be
184
186
185
187
### Adding default dimensions
186
188
187
-
You can add default dimensions to your metrics by passing them as parameters in 4 ways:
189
+
You can add default dimensions to your metrics by passing them as parameters in 4 ways:
188
190
189
191
* in the constructor
190
192
* in the [Middy-compatible](https://github.com/middyjs/middy){target=_blank} middleware
@@ -405,6 +407,28 @@ This has the advantage of keeping cold start metric separate from your applicati
405
407
406
408
!!! info "We do not emit 0 as a value for the ColdStart metric for cost-efficiency reasons. [Let us know](https://github.com/aws-powertools/powertools-lambda-typescript/issues/new?assignees=&labels=feature-request%2C+triage&template=feature_request.md&title=) if you'd prefer a flag to override it."
407
409
410
+
#### Setting function name
411
+
412
+
When emitting cold start metrics, the `function_name` dimension defaults to `context.functionName`. If you want to change the value you can set the `functionName` parameter in the metrics constructor, define the environment variable `POWERTOOLS_METRICS_FUNCTION_NAME`, or pass a value to `captureColdStartMetric`.
413
+
414
+
The priority of the `function_name` dimension value is defined as:
|**POWERTOOLS_DEV**| Increase JSON indentation to ease debugging when running functions locally or in a non-production environment |[Logger](core/logger.md)|`false`|
366
-
|**POWERTOOLS_LOG_LEVEL**| Sets how verbose Logger should be, from the most verbose to the least verbose (no logs) |[Logger](core/logger.md)|`INFO`|
367
-
|**POWERTOOLS_PARAMETERS_MAX_AGE**| Adjust how long values are kept in cache (in seconds) |[Parameters](utilities/parameters.md)|`5`|
368
-
|**POWERTOOLS_PARAMETERS_SSM_DECRYPT**| Set whether to decrypt or not values retrieved from AWS Systems Manager Parameters Store |[Parameters](utilities/parameters.md)|`false`|
369
-
|**POWERTOOLS_IDEMPOTENCY_DISABLED**| Disable the Idempotency logic without changing your code, useful for testing |[Idempotency](utilities/idempotency.md)|`false`|
|**POWERTOOLS_SERVICE_NAME**| Set service name used for tracing namespace, metrics dimension and structured logging | All |`service_undefined`|
357
+
|**POWERTOOLS_METRICS_NAMESPACE**| Set namespace used for metrics |[Metrics](core/metrics.md)|`default_namespace`|
358
+
|**POWERTOOLS_METRICS_FUNCTION_NAME**| Function name used as dimension for the `ColdStart` metric |[Metrics](core/metrics.md)|[See docs](core/metrics/#setting-function-name)|
359
+
|**POWERTOOLS_METRICS_ENABLED**| Explicitly disables emitting metrics to stdout |[Metrics](core/metrics.md)|`true`|
|**POWERTOOLS_DEV**| Pretty-print logs, disable metrics flushing, and disable traces - use for dev only | See section below |`false`|
367
+
|**POWERTOOLS_LOG_LEVEL**| Sets how verbose Logger should be, from the most verbose to the least verbose (no logs) |[Logger](core/logger.md)|`INFO`|
368
+
|**POWERTOOLS_PARAMETERS_MAX_AGE**| Adjust how long values are kept in cache (in seconds) |[Parameters](utilities/parameters.md)|`5`|
369
+
|**POWERTOOLS_PARAMETERS_SSM_DECRYPT**| Set whether to decrypt or not values retrieved from AWS Systems Manager Parameters Store |[Parameters](utilities/parameters.md)|`false`|
370
+
|**POWERTOOLS_IDEMPOTENCY_DISABLED**| Disable the Idempotency logic without changing your code, useful for testing |[Idempotency](utilities/idempotency.md)|`false`|
370
371
371
372
Each Utility page provides information on example values and allowed values.
* @param functionName - Optional function name to use as `function_name` dimension in the metric. It's used only if the `functionName` constructor parameter or environment variable are not set.
0 commit comments