References
Environment variables
Info
Explicit parameters take precedence over environment variables.
Environment variable |
Description |
Utility |
Default |
POWERTOOLS_SERVICE_NAME |
Sets service name used for tracing namespace, metrics dimension and structured logging |
All |
"service_undefined" |
POWERTOOLS_LOG_LEVEL |
Sets logging level |
Logging |
Information |
POWERTOOLS_LOGGER_CASE |
Override the default casing for log keys |
Logging |
SnakeCase |
POWERTOOLS_LOGGER_LOG_EVENT |
Logs incoming event |
Logging |
false |
POWERTOOLS_LOGGER_SAMPLE_RATE |
Debug log sampling |
Logging |
0 |
POWERTOOLS_METRICS_NAMESPACE |
Sets namespace used for metrics |
Metrics |
None |
POWERTOOLS_TRACE_DISABLED |
Disables tracing |
Tracing |
false |
POWERTOOLS_TRACER_CAPTURE_RESPONSE |
Captures Lambda or method return as metadata. |
Tracing |
true |
POWERTOOLS_TRACER_CAPTURE_ERROR |
Captures Lambda or method exception as metadata. |
Tracing |
true |
SAM template snippets
Logging
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
Example project for Powertools for AWS Lambda (.NET) Logging utility
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: powertools-dotnet-logging-sample
POWERTOOLS_LOG_LEVEL: Debug
POWERTOOLS_LOGGER_LOG_EVENT: true
POWERTOOLS_LOGGER_CASE: PascalCase # Allowed values are: CamelCase, PascalCase and SnakeCase
POWERTOOLS_LOGGER_SAMPLE_RATE: 0
|
Metrics
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
Example project for Powertools for AWS Lambda (.NET) Metrics utility
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: powertools-dotnet-metrics-sample # This can also be set using the Metrics decorator on your handler [Metrics(Namespace = "aws-lambda-powertools"]
POWERTOOLS_METRICS_NAMESPACE: AWSLambdaPowertools # This can also be set using the Metrics decorator on your handler [Metrics(Namespace = "aws-lambda-powertools"]
|
Tracing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
Example project for Powertools for AWS Lambda (.NET) tracing utility
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 10
Tracing: Active
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: powertools-dotnet-tracing-sample
POWERTOOLS_TRACE_DISABLED: true
POWERTOOLS_TRACER_CAPTURE_RESPONSE: true
POWERTOOLS_TRACER_CAPTURE_ERROR: true # To disable tracing (CaptureMode = TracingCaptureMode.Disabled)
|