Feature request: ability to silence / skip publishing metrics via env variable #3329
Closed
2 tasks done
Labels
confirmed
The scope is clear, ready for implementation
feature-request
This item refers to a feature request for an existing or new utility
help-wanted
We would really appreciate some support from community for this one
metrics
This item relates to the Metrics Utility
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
POWERTOOLS_METRICS_DISABLED
env variable is present and truthy when theMetrics
class is instantiated, then it becomes disabledPOWERTOOLS_DEV
which can be checked with this method, when theMetrics
class is instantiated, then it also becomes disabledPOWERTOOLS_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
Future readers
Please react with 👍 and your use case to help us understand customer demand.
The text was updated successfully, but these errors were encountered: