forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into issue/242
* develop: chore: move env names to constant file (#264) docs: fix import (#267) feat: Add AppConfig parameter provider (#236) chore: update stale bot improv: override Tracer auto-capture response/exception via env vars (#259) docs: add info about extras layer (#260) feat: support extra parameter in Logger messages (#257) chore: general simplifications and cleanup (#255)
- Loading branch information
Showing
27 changed files
with
812 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
TRACER_CAPTURE_RESPONSE_ENV: str = "POWERTOOLS_TRACER_CAPTURE_RESPONSE" | ||
TRACER_CAPTURE_ERROR_ENV: str = "POWERTOOLS_TRACER_CAPTURE_ERROR" | ||
TRACER_DISABLED_ENV: str = "POWERTOOLS_TRACE_DISABLED" | ||
|
||
LOGGER_LOG_SAMPLING_RATE: str = "POWERTOOLS_LOGGER_SAMPLE_RATE" | ||
LOGGER_LOG_EVENT_ENV: str = "POWERTOOLS_LOGGER_LOG_EVENT" | ||
|
||
MIDDLEWARE_FACTORY_TRACE_ENV: str = "POWERTOOLS_TRACE_MIDDLEWARES" | ||
|
||
METRICS_NAMESPACE_ENV: str = "POWERTOOLS_METRICS_NAMESPACE" | ||
|
||
SAM_LOCAL_ENV: str = "AWS_SAM_LOCAL" | ||
CHALICE_LOCAL_ENV: str = "AWS_CHALICE_CLI_MODE" | ||
SERVICE_NAME_ENV: str = "POWERTOOLS_SERVICE_NAME" | ||
XRAY_TRACE_ID_ENV: str = "_X_AMZN_TRACE_ID" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from distutils.util import strtobool | ||
from typing import Any, Union | ||
|
||
|
||
def resolve_truthy_env_var_choice(env: Any, choice: bool = None) -> bool: | ||
""" Pick explicit choice over truthy env value, if available, otherwise return truthy env value | ||
NOTE: Environment variable should be resolved by the caller. | ||
Parameters | ||
---------- | ||
env : Any | ||
environment variable actual value | ||
choice : bool | ||
explicit choice | ||
Returns | ||
------- | ||
choice : str | ||
resolved choice as either bool or environment value | ||
""" | ||
return choice if choice is not None else strtobool(env) | ||
|
||
|
||
def resolve_env_var_choice(env: Any, choice: bool = None) -> Union[bool, Any]: | ||
""" Pick explicit choice over env, if available, otherwise return env value received | ||
NOTE: Environment variable should be resolved by the caller. | ||
Parameters | ||
---------- | ||
env : Any | ||
environment variable actual value | ||
choice : bool | ||
explicit choice | ||
Returns | ||
------- | ||
choice : str | ||
resolved choice as either bool or environment value | ||
""" | ||
return choice if choice is not None else env |
Oops, something went wrong.