Skip to content

Commit 80f3264

Browse files
authored
chore(rcm): payload logging (#7603)
We add a private environment variable to enable logging of the remote configuration client request and response payloads. This is intended to be used to debug issues involving the RCM payloads in the client library. ## Checklist - [x] Change(s) are motivated and described in the PR description. - [x] Testing strategy is described if automated tests are not included in the PR. - [x] Risk is outlined (performance impact, potential for breakage, maintainability, etc). - [x] Change is maintainable (easy to change, telemetry, documentation). - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed. If no release note is required, add label `changelog/no-changelog`. - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)). - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [ ] Title is accurate. - [ ] No unnecessary changes are introduced. - [ ] Description motivates each change. - [ ] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes unless absolutely necessary. - [ ] Testing strategy adequately addresses listed risk(s). - [ ] Change is maintainable (easy to change, telemetry, documentation). - [ ] Release note makes sense to a user of the library. - [ ] Reviewer has explicitly acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment. - [ ] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting) - [ ] If this PR touches code that signs or publishes builds or packages, or handles credentials of any kind, I've requested a review from `@DataDog/security-design-and-guidance`. - [ ] This PR doesn't touch any of that.
1 parent 1656e7d commit 80f3264

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ddtrace/internal/remoteconfig/client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import attr
1818
import cattr
19+
from envier import En
1920
import six
2021

2122
import ddtrace
@@ -46,6 +47,15 @@
4647
TARGET_FORMAT = re.compile(r"^(datadog/\d+|employee)/([^/]+)/([^/]+)/([^/]+)$")
4748

4849

50+
class RemoteConfigClientConfig(En):
51+
__prefix__ = "_dd.remote_configuration"
52+
53+
log_payloads = En.v(bool, "log_payloads", default=False)
54+
55+
56+
config = RemoteConfigClientConfig()
57+
58+
4959
class RemoteConfigError(Exception):
5060
"""
5161
An error occurred during the configuration update procedure.
@@ -275,10 +285,19 @@ def _send_request(self, payload):
275285
log.debug(
276286
"[%s][P: %s] Requesting RC data from products: %s", os.getpid(), os.getppid(), str(self._products)
277287
) # noqa: G200
288+
289+
if config.log_payloads:
290+
log.debug("[%s][P: %s] RC request payload: %s", os.getpid(), os.getppid(), payload) # noqa: G200
291+
278292
conn = agent.get_connection(self.agent_url, timeout=ddtrace.config._agent_timeout_seconds)
279293
conn.request("POST", REMOTE_CONFIG_AGENT_ENDPOINT, payload, self._headers)
280294
resp = conn.getresponse()
281295
data = resp.read()
296+
297+
if config.log_payloads:
298+
log.debug(
299+
"[%s][P: %s] RC response payload: %s", os.getpid(), os.getppid(), data.decode("utf-8")
300+
) # noqa: G200
282301
except OSError as e:
283302
log.debug("Unexpected connection error in remote config client request: %s", str(e)) # noqa: G200
284303
return None

0 commit comments

Comments
 (0)