Skip to content

Environment variable to disable statsd in development #576

@wilhelmklopp

Description

@wilhelmklopp

Is your feature request related to a problem? Please describe.

Hi! We use the statsd part of this library in a django app to send metrics to Datadog when making API calls to a third party service (tracking things like status code and response times). In development, those API calls still happen, but we don't have the local datadog agent running.

As a result we get errors such as Error submitting packet: [Errno 61] Connection refused, dropping the packet and closing the socket" which tend to clutter the command line output.

Describe the solution you'd like
Would love if there was an environment variable we could set in development that would disable any statsd metric collection, perhaps DATADOG_DISABLE_STATSD?

Describe alternatives you've considered
Some alternative global "disable" option that isn't necessarily an environment variable would also work. For example with ddtrace we can disable it in development by putting the following in the django settings.py file:

DATADOG_TRACE = {
    "ENABLED": os.environ["DDTRACE_ENABLED"] == "True",
}

Another option we considered was to manually add some conditionals around each of our uses of statsd in the codebase to check if the app is running in development, but since we use it in quite a few places we felt this would be quite a messy approach. Similarly, trying to manually override the imported statsd module when the app is running in development felt like a not-so-great solution.

Additional context
It looks like there was a previous issue about this: #296

Thanks a lot for making this! We're big fans of Datadog ✌️

cc @ThomasSydney

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions