Skip to content

Feature request: ability to silence / skip publishing metrics via env variable #3329

Closed
@dreamorosi

Description

@dreamorosi

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 the Metrics 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 the Metrics class is instantiated, then it also becomes disabled
  • If POWERTOOLS_METRICS_DISABLED is set to false, and dev mode is enabled, then POWERTOOLS_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.

Metadata

Metadata

Assignees

Labels

confirmedThe scope is clear, ready for implementationfeature-requestThis item refers to a feature request for an existing or new utilityhelp-wantedWe would really appreciate some support from community for this onemetricsThis item relates to the Metrics Utility

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions