Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 15 additions & 5 deletions newrelic/common/agent_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def __init__(
audit_log_fp=None,
default_content_encoding_header="Identity",
):
self._host = host
self._audit_log_fp = audit_log_fp

def __enter__(self):
Expand Down Expand Up @@ -565,12 +566,20 @@ class DeveloperModeClient(SupportabilityMixin, BaseClient):
def send_request(
self, method="POST", path="/agent_listener/invoke_raw_method", params=None, headers=None, payload=None
):
request_id = self.log_request(
self._audit_log_fp, "POST", f"https://fake-collector.newrelic.com{path}", params, payload, headers
)
# Pre-connect and OTLP endpoint requests will not have the fake- prefix, so we forcibly add it just to be sure.
host = self._host if self._host.startswith("fake-") else f"fake-{self._host}"
url = f"https://{host}{path}"
request_id = self.log_request(self._audit_log_fp, "POST", url, params, payload, headers)

# Don't attempt to handle OTLP endpoint requests
if host == "fake-otlp.nr-data.net":
return 200, b""

# Requests to the collector must have a method parameter or they're invalid
if not params or "method" not in params:
return 400, b"Missing method parameter"

# If we don't have a canned response for the method, return an error
method = params["method"]
if method not in self.RESPONSES:
return 400, b"Invalid method received"
Expand All @@ -592,8 +601,9 @@ def send_request(
):
result = super().send_request(method=method, path=path, params=params, headers=headers, payload=payload)

if result[0] == 200:
agent_method = params["method"]
# Check for the presence of agent_method to ensure this isn't an OTLP request
agent_method = params and params.get("method")
if result[0] == 200 and agent_method:
self.payload[agent_method] = json_decode(payload.decode("utf-8"))

return result
Expand Down
5 changes: 2 additions & 3 deletions newrelic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,9 +689,8 @@ def default_otlp_host(host):
}
otlp_host = HOST_MAP.get(host, None)
if not otlp_host:
default = HOST_MAP["collector.newrelic.com"]
_logger.warning("Unable to find corresponding OTLP host using default %s", default)
otlp_host = default
otlp_host = HOST_MAP["collector.newrelic.com"]
_logger.warning("Unable to find corresponding OTLP host using default %s", otlp_host)
return otlp_host


Expand Down
34 changes: 0 additions & 34 deletions tests/agent_benchmarks/bench_agent_active.py

This file was deleted.

Loading
Loading