Skip to content

docs: Add environment variable table #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/core/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Logging requires two settings:

Setting | Description | Environment variable | Attribute parameter
------------------------------------------------- | ------------------------------------------------- | ------------------------------------------------- | -------------------------------------------------
**Logging level** | Sets how verbose Logger should be (Information, by default) | `LOG_LEVEL` | `LogLevel`
**Logging level** | Sets how verbose Logger should be (Information, by default) | `POWERTOOLS_LOG_LEVEL` | `LogLevel`
**Service** | Sets **Service** key that will be present across all log statements | `POWERTOOLS_SERVICE_NAME` | `Service`

### Example using AWS Serverless Application Model (AWS SAM)
Expand Down Expand Up @@ -63,7 +63,7 @@ Key | Type | Example | Description

## Logging incoming event

When debugging in non-production environments, you can instruct Logger to log the incoming event with `LogEvent` parameter or via POWERTOOLS_LOGGER_LOG_EVENT environment variable.
When debugging in non-production environments, you can instruct Logger to log the incoming event with `LogEvent` parameter or via `POWERTOOLS_LOGGER_LOG_EVENT` environment variable.

!!! warning
Log event is disabled by default to prevent sensitive info being logged.
Expand Down
76 changes: 71 additions & 5 deletions docs/references.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,80 @@ description: AWS Lambda Powertools for .NET references
| 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](./core/logger) | `Information` |
| **POWERTOOLS_LOGGER_CASE** | Override the default casing for log keys | [Logging](./core/logging/#configure-log-output-casing) | `SnakeCase` |
| **POWERTOOLS_LOGGER_LOG_EVENT** | Logs incoming event | [Logging](./core/logging) | `false` |
| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging) | `0` |
| **POWERTOOLS_METRICS_NAMESPACE** | Sets namespace used for metrics | [Metrics](./core/metrics) | `None` |
| **POWERTOOLS_TRACE_DISABLED** | Disables tracing | [Tracing](./core/tracing) | `false` |
| **POWERTOOLS_TRACER_CAPTURE_RESPONSE** | Captures Lambda or method return as metadata. | [Tracing](./core/tracing) | `true` |
| **POWERTOOLS_TRACER_CAPTURE_ERROR** | Captures Lambda or method exception as metadata. | [Tracing](./core/tracing) | `true` |
| **POWERTOOLS_LOGGER_LOG_EVENT** | Logs incoming event | [Logging](./core/logging) | `false` |
| **POWERTOOLS_LOGGER_SAMPLE_RATE** | Debug log sampling | [Logging](./core/logging) | `0` |
| **POWERTOOLS_LOG_DEDUPLICATION_DISABLED** | Disables log deduplication filter protection to use Pytest Live Log feature | [Logging](./core/logging) | `false` |

## SAM template snippets

TODO....

### Logging

```yaml
# 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 AWS Lambda Powertools 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_LOGGER_LOG_EVENT: true
POWERTOOLS_LOG_LEVEL: Debug
POWERTOOLS_LOGGER_CASE: SnakeCase # Allowed values are: CamelCase, PascalCase and SnakeCase

```

### Metrics

```yaml
# 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 AWS Lambda Powertools 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

```yaml
# 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 AWS Lambda Powertools 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)

```
4 changes: 2 additions & 2 deletions libraries/src/AWS.Lambda.Powertools.Common/Core/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ internal static class Constants
internal const string MetricsNamespaceEnv = "POWERTOOLS_METRICS_NAMESPACE";

/// <summary>
/// Constant for LOG_LEVEL environment variable
/// Constant for POWERTOOLS_LOG_LEVEL environment variable
/// </summary>
internal const string LogLevelNameEnv = "LOG_LEVEL";
internal const string LogLevelNameEnv = "POWERTOOLS_LOG_LEVEL";

/// <summary>
/// Constant for POWERTOOLS_LOGGER_SAMPLE_RATE environment variable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LoggerConfiguration : IOptions<LoggerConfiguration>

/// <summary>
/// Specify the minimum log level for logging (Information, by default).
/// This can be also set using the environment variable <c>LOG_LEVEL</c>.
/// This can be also set using the environment variable <c>POWERTOOLS_LOG_LEVEL</c>.
/// </summary>
/// <value>The minimum level.</value>
public LogLevel? MinimumLevel { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class LoggingAttribute : MethodAspectAttribute

/// <summary>
/// Specify the minimum log level for logging (Information, by default).
/// This can be also set using the environment variable <c>LOG_LEVEL</c>.
/// This can be also set using the environment variable <c>POWERTOOLS_LOG_LEVEL</c>.
/// </summary>
/// <value>The log level.</value>
public LogLevel LogLevel
Expand Down