Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rcm): get connection on every request #6753

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ddtrace/internal/remoteconfig/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ def __init__(self):
tracer_version = _pep440_to_semver()

self.id = str(uuid.uuid4())
self.agent_url = agent_url = agent.get_trace_url()
self._conn = agent.get_connection(agent_url, timeout=agent.get_trace_agent_timeout())
self.agent_url = agent.get_trace_url()

self._headers = {"content-type": "application/json"}
additional_header_str = os.environ.get("_DD_REMOTE_CONFIGURATION_ADDITIONAL_HEADERS")
Expand Down Expand Up @@ -257,14 +256,15 @@ def _send_request(self, payload):
log.debug(
"[%s][P: %s] Requesting RC data from products: %s", os.getpid(), os.getppid(), str(self._products)
) # noqa: G200
self._conn.request("POST", REMOTE_CONFIG_AGENT_ENDPOINT, payload, self._headers)
resp = self._conn.getresponse()
conn = agent.get_connection(self.agent_url, timeout=agent.get_trace_agent_timeout())
conn.request("POST", REMOTE_CONFIG_AGENT_ENDPOINT, payload, self._headers)
resp = conn.getresponse()
data = resp.read()
except OSError as e:
log.debug("Unexpected connection error in remote config client request: %s", str(e)) # noqa: G200
return None
finally:
self._conn.close()
conn.close()

if resp.status == 404:
# Remote configuration is not enabled or unsupported by the agent
Expand Down