-
Notifications
You must be signed in to change notification settings - Fork 318
Description
Given the current behaviour of datadog.initialize, there's potential for a subsequent call to it to wipe out previous API config, which I think is unnecessary and could create annoying bugs.
If I do:
import datadog
API_KEY="thisisakey"
datadog.initialize(api_key=API_KEY)
...
# some other code somewhere later
datadog.initialize(statsd_host=os.environ.get("DOGSTATSD_HOST_IP", "localhost"))
My api_key will no longer be set because of this code -> https://github.com/DataDog/datadogpy/blob/master/datadog/__init__.py#L73
I think it would be quite straightforward to change the above code to first check if _api_key is already set, and not override it with the os.environ.get call. Then datadog.intialize would be more predictable :).
More broadly, I think the mutable state in datadog.api and datadog.statsd makes initilization/config management harder to manager.
Sidenote: I think this issue is expressing related concerns about datadog.initialize #347