Closed
Description
Use case
Discussed in #3315
Originally posted by zirkelc November 14, 2024
Hi,
I wanted to know if it is possible to silence metrics based on an environment variable in the same way it is possible to silence logs.
Basically, I want to omit publishing metrics if the environment is not production. Ideally, that should be controllable with an env var.
Solution/User Experience
- by default, Metrics is enabled (current behavior)
- if the
POWERTOOLS_METRICS_DISABLED
env variable is present and truthy when theMetrics
class is instantiated, then it becomes disabled - if dev mode is enabled by means of
POWERTOOLS_DEV
which can be checked with this method, when theMetrics
class is instantiated, then it also becomes disabled - If
POWERTOOLS_METRICS_DISABLED
is set tofalse
, and dev mode is enabled, thenPOWERTOOLS_METRICS_DISABLED
takes precedence and the utility stays enabled.
Alternative solutions
N/A
Acknowledgment
- This feature request meets Powertools for AWS Lambda (TypeScript) Tenets
- Should this be considered in other Powertools for AWS Lambda languages? i.e. Python, Java, and .NET
Future readers
Please react with 👍 and your use case to help us understand customer demand.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped