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

Fix remote dependency target field format #1138

Merged
merged 1 commit into from
Nov 5, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,21 @@ private void endInternal() {
}
try {
URI uriObject = new URI(uri);
String target;
if (requestContext == null) {
target = uriObject.getHost();
} else {
target = sdkBridge.generateChildDependencyTarget(requestContext, Global.isOutboundW3CEnabled());
String target = createTarget(uriObject);
if (requestContext != null) {
String incomingTarget =
sdkBridge.generateChildDependencyTarget(requestContext, Global.isOutboundW3CEnabled());
if (incomingTarget != null && !incomingTarget.isEmpty()) {
target += " | " + incomingTarget;
}
}
telemetry.setTarget(target);
String path = uriObject.getPath();
if (Strings.isNullOrEmpty(path)) {
telemetry.setName(method + " /");
} else {
telemetry.setName(method + " " + path);
}
if (target != null && !target.isEmpty()) {
// AI correlation expects target to be of this format.
telemetry.setTarget(createTarget(uriObject, target));
}
} catch (URISyntaxException e) {
logger.error(e.getMessage());
logger.debug(e.getMessage(), e);
Expand All @@ -188,12 +187,11 @@ private void endInternal() {
}

// from CoreAgentNotificationsHandler:
private static String createTarget(URI uriObject, String incomingTarget) {
private static String createTarget(URI uriObject) {
String target = uriObject.getHost();
if (uriObject.getPort() != 80 && uriObject.getPort() != 443) {
if (uriObject.getPort() != 80 && uriObject.getPort() != 443 && uriObject.getPort() != -1) {
target += ":" + uriObject.getPort();
}
target += " | " + incomingTarget;
return target;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void testAsyncDependencyCallWithApacheHttpClient4() throws Exception {

assertTrue(rd.getSuccess());
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(rd.getId()));
}

Expand All @@ -43,7 +43,7 @@ public void testAsyncDependencyCallWithApacheHttpClient4WithResponseHandler() th

assertTrue(rd.getSuccess());
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(rd.getId()));
}

Expand All @@ -58,7 +58,7 @@ public void testAsyncDependencyCallWithApacheHttpClient3() throws Exception {

assertTrue(rd.getSuccess());
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(rd.getId()));
}

Expand All @@ -73,7 +73,7 @@ public void testAsyncDependencyCallWithOkHttp3() throws Exception {

assertTrue(rd.getSuccess());
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(rd.getId()));
}

Expand All @@ -88,7 +88,7 @@ public void testAsyncDependencyCallWithOkHttp2() throws Exception {

assertTrue(rd.getSuccess());
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(rd.getId()));
}

Expand All @@ -103,7 +103,7 @@ public void testAsyncDependencyCallWithHttpURLConnection() throws Exception {

assertTrue(rd.getSuccess());
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(rd.getId()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private static void commonValidation() throws Exception {
RemoteDependencyData rdd = (RemoteDependencyData) ((Data) rddEnvelope.getData()).getBaseData();

assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertEquals("www.bing.com", rdd.getTarget());

assertTrue(rdd.getId().contains(d.getId()));
assertSameOperationId(rdEnvelope, rddEnvelope);
Expand Down