|
16 | 16 |
|
17 | 17 | import attr |
18 | 18 | import cattr |
| 19 | +from envier import En |
19 | 20 | import six |
20 | 21 |
|
21 | 22 | import ddtrace |
|
46 | 47 | TARGET_FORMAT = re.compile(r"^(datadog/\d+|employee)/([^/]+)/([^/]+)/([^/]+)$") |
47 | 48 |
|
48 | 49 |
|
| 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 | + |
49 | 59 | class RemoteConfigError(Exception): |
50 | 60 | """ |
51 | 61 | An error occurred during the configuration update procedure. |
@@ -275,10 +285,19 @@ def _send_request(self, payload): |
275 | 285 | log.debug( |
276 | 286 | "[%s][P: %s] Requesting RC data from products: %s", os.getpid(), os.getppid(), str(self._products) |
277 | 287 | ) # 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 | + |
278 | 292 | conn = agent.get_connection(self.agent_url, timeout=ddtrace.config._agent_timeout_seconds) |
279 | 293 | conn.request("POST", REMOTE_CONFIG_AGENT_ENDPOINT, payload, self._headers) |
280 | 294 | resp = conn.getresponse() |
281 | 295 | 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 |
282 | 301 | except OSError as e: |
283 | 302 | log.debug("Unexpected connection error in remote config client request: %s", str(e)) # noqa: G200 |
284 | 303 | return None |
|
0 commit comments