Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,14 @@ private void processInfoResponseHeaders(Response response) {
private boolean processInfoResponse(State newState, String response) {
try {
Map<String, Object> map = RESPONSE_ADAPTER.fromJson(response);
final Object endpointObj = map.get("endpoints");
if (!(endpointObj instanceof List)) {
log.debug("Bad response received from the agent. Ignoring it.");
return false;
}
discoverStatsDPort(map);
newState.version = (String) map.get("version");
Set<String> endpoints = new HashSet<>((List<String>) map.get("endpoints"));
Set<String> endpoints = new HashSet<>((List<String>) endpointObj);

String foundMetricsEndpoint = null;
if (metricsEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,28 @@ class DDAgentFeaturesDiscoveryTest extends DDSpecification {
0 * _
}

def "test fallback when /info empty"() {
setup:
OkHttpClient client = Mock(OkHttpClient)
DDAgentFeaturesDiscovery features = new DDAgentFeaturesDiscovery(client, monitoring, agentUrl, false, true)

when: "/info is empty"
features.discover()

then:
1 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/info" }) >> { Request request -> infoResponse(request, "{}") }
0 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/v0.6/stats" }) >> { Request request -> clientError(request) }
0 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/v0.5/traces" }) >> { Request request -> success(request) }
1 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/v0.4/traces" }) >> { Request request -> success(request) }
0 * client.newCall({ Request request -> request.url().toString() == "http://localhost:8125/v0.3/traces" }) >> { Request request -> success(request) }
features.getMetricsEndpoint() == null
!features.supportsMetrics()
features.getTraceEndpoint() == V04_ENDPOINT
!features.supportsLongRunning()
features.state() == PROBE_STATE
0 * _
}

def "test fallback when /info not found"() {
setup:
OkHttpClient client = Mock(OkHttpClient)
Expand Down
Loading