Skip to content

Commit a41e8b4

Browse files
avara1986gnufedemabdinurjuanjuxmajorgreys
authored
feat: rename DD_REMOTECONFIG_POLL_SECONDS env var (#4885)
## Description `DD_REMOTECONFIG_POLL_SECONDS` environment variable is deprecated in favor of `DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS` ## Reviewer Checklist - [ ] Title is accurate. - [ ] Description motivates each change. - [ ] No unnecessary changes were introduced in this PR. - [ ] Avoid breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Tests provided or description of manual testing performed is included in the code or PR. - [ ] Release note has been added and follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/contributing.html#Release-Note-Guidelines), or else `changelog/no-changelog` label added. - [ ] All relevant GitHub issues are correctly linked. - [ ] Backports are identified and tagged with Mergifyio. Co-authored-by: Federico Mon <[email protected]> Co-authored-by: Munir Abdinur <[email protected]> Co-authored-by: Juanjo Alvarez Martinez <[email protected]> Co-authored-by: Tahir H. Butt <[email protected]>
1 parent 58249cf commit a41e8b4

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

ddtrace/internal/remoteconfig/worker.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from ddtrace.internal.logger import get_logger
66
from ddtrace.internal.remoteconfig.client import RemoteConfigClient
77
from ddtrace.internal.utils.time import StopWatch
8+
from ddtrace.vendor.debtcollector import deprecate
89

910

1011
log = get_logger(__name__)
@@ -15,7 +16,18 @@
1516

1617
def get_poll_interval_seconds():
1718
# type:() -> float
18-
return float(os.getenv("DD_REMOTECONFIG_POLL_SECONDS", default=DEFAULT_REMOTECONFIG_POLL_SECONDS))
19+
if os.getenv("DD_REMOTECONFIG_POLL_SECONDS"):
20+
deprecate(
21+
"Using environment variable 'DD_REMOTECONFIG_POLL_SECONDS' is deprecated",
22+
message="Please use DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS instead.",
23+
removal_version="2.0.0",
24+
)
25+
return float(
26+
os.getenv(
27+
"DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS",
28+
default=os.getenv("DD_REMOTECONFIG_POLL_SECONDS", default=DEFAULT_REMOTECONFIG_POLL_SECONDS),
29+
)
30+
)
1931

2032

2133
class RemoteConfigWorker(periodic.PeriodicService):
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
deprecations:
3+
- |
4+
``DD_REMOTECONFIG_POLL_SECONDS`` environment variable is deprecated and will be removed in v2.0. Please use ``DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS`` instead.

setup.cfg

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@ addopts =
4242
--junitxml=test-results/junit.xml
4343
# DEV: The default is `test_*\.py` which will miss `test.py` files
4444
python_files = test*\.py
45-
filterwarnings =
46-
# Show any DeprecationWarnings once
47-
once::DeprecationWarning
4845
asyncio_mode = auto

tests/debugging/test_debugger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ def test_debugger_line_probe_on_wrapped_function(stuff):
668668
def test_probe_status_logging(mock_check_remote_config_enable_in_agent, monkeypatch):
669669
mock_check_remote_config_enable_in_agent.return_value = True
670670

671-
monkeypatch.setenv("DD_REMOTECONFIG_POLL_SECONDS", "0.1")
671+
monkeypatch.setenv("DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS", "0.1")
672672
RemoteConfig.disable()
673673

674674
from ddtrace.internal.remoteconfig.client import RemoteConfigClient

tests/internal/test_remoteconfig.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import re
77
from time import sleep
8+
import warnings
89

910
import mock
1011
import pytest
@@ -14,6 +15,7 @@
1415
from ddtrace.internal.remoteconfig.client import RemoteConfigClient
1516
from ddtrace.internal.remoteconfig.constants import ASM_FEATURES_PRODUCT
1617
from ddtrace.internal.remoteconfig.constants import REMOTE_CONFIG_AGENT_ENDPOINT
18+
from ddtrace.internal.remoteconfig.worker import get_poll_interval_seconds
1719
from tests.utils import override_env
1820

1921

@@ -137,7 +139,7 @@ def _reload_features(self, metadata, features):
137139

138140
callback = Callback()
139141

140-
with override_env(dict(DD_REMOTECONFIG_POLL_SECONDS="0.1")):
142+
with override_env(dict(DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS="0.1")):
141143
mock_check_remote_config_enable_in_agent.return_value = True
142144
mock_send_request.return_value = get_mock_encoded_msg(b'{"asm":{"enabled":true}}')
143145
rc = RemoteConfig()
@@ -147,6 +149,29 @@ def _reload_features(self, metadata, features):
147149
assert callback.features == {"asm": {"enabled": True}}
148150

149151

152+
def test_remote_configuration_check_deprecated_var():
153+
with override_env(dict(DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS="0.1")):
154+
with warnings.catch_warnings(record=True) as capture:
155+
get_poll_interval_seconds()
156+
assert len(capture) == 0
157+
158+
159+
def test_remote_configuration_check_deprecated_var_message():
160+
with override_env(dict(DD_REMOTECONFIG_POLL_SECONDS="0.1")):
161+
with warnings.catch_warnings(record=True) as capture:
162+
get_poll_interval_seconds()
163+
assert len(capture) == 1
164+
assert str(capture[0].message).startswith("Using environment")
165+
166+
167+
def test_remote_configuration_check_deprecated_override():
168+
with override_env(dict(DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS="0.1", DD_REMOTECONFIG_POLL_SECONDS="0.5")):
169+
with warnings.catch_warnings(record=True) as capture:
170+
assert get_poll_interval_seconds() == 0.1
171+
assert len(capture) == 1
172+
assert str(capture[0].message).startswith("Using environment")
173+
174+
150175
def test_remoteconfig_semver():
151176
assert re.match(
152177
r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*["

0 commit comments

Comments
 (0)