Skip to content

Commit

Permalink
Merge pull request #1025 from microsoft/fix-http-remote-dependency-ca…
Browse files Browse the repository at this point in the history
…pture

Fix http remote dependency capture
  • Loading branch information
trask authored Aug 21, 2019
2 parents 5814fca + 6568775 commit 543043b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
2 changes: 1 addition & 1 deletion agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plugins {
apply from: "$buildScriptsDir/common-java.gradle"
apply from: "$buildScriptsDir/publishing.gradle"

def instrumentationVersion = '0.14.2'
def instrumentationVersion = '0.14.3'

def shadowPrefix = 'com.microsoft.applicationinsights.agent.shadow'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ private static void start(Instrumentation instrumentation, File agentJarFile) th
AIAgentXmlLoader.getInstrumentationConfig(builtInInstrumentation));

EngineModule.createWithSomeDefaults(instrumentation, tmpDir, Global.getThreadContextThreadLocal(),
instrumentationDescriptors, configServiceFactory, new AgentImpl(),
instrumentationDescriptors, configServiceFactory, new AgentImpl(), false,
Collections.singletonList("com.microsoft.applicationinsights.agent"),
Collections.singletonList("com.microsoft.applicationinsights.agent"), agentJarFile);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.net.URISyntaxException;
import java.util.Map;

import com.google.common.base.Strings;
import com.microsoft.applicationinsights.agent.internal.sdk.SdkBridge;
import com.microsoft.applicationinsights.agent.internal.sdk.SdkBridge.ExceptionTelemetry;
import com.microsoft.applicationinsights.agent.internal.sdk.SdkBridge.RemoteDependencyTelemetry;
Expand Down Expand Up @@ -157,7 +158,12 @@ private void endInternal() {
} else {
target = sdkBridge.generateChildDependencyTarget(requestContext, Global.isOutboundW3CEnabled());
}
telemetry.setName(method + " " + uriObject.getPath());
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));
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ archivesBaseName = 'applicationinsights-core'

dependencies {
compileOnly (project(':agent')) { transitive = false }
compileOnly ([group: 'org.glowroot.instrumentation', name: 'instrumentation-api', version: '0.14.2']) { transitive = false }
compileOnly ([group: 'org.glowroot.instrumentation', name: 'instrumentation-api', version: '0.14.3']) { transitive = false }
compile(project(':ApplicationInsightsInternalLogger'))
compile ([group: 'eu.infomas', name: 'annotation-detector', version: '3.0.5'])
compile ([group: 'commons-io', name: 'commons-io', version: '2.6' ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public void testAsyncDependencyCallWithApacheHttpClient4() {
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
RequestData d = getTelemetryDataForType(0, "RequestData");
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
String requestOperationId = d.getId();
String rddId = rdd.getId();
assertTrue(rddId.contains(requestOperationId));
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(d.getId()));
}

@Test
Expand All @@ -101,9 +101,9 @@ public void testAsyncDependencyCallWithApacheHttpClient3() {
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
RequestData d = getTelemetryDataForType(0, "RequestData");
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
String requestOperationId = d.getId();
String rddId = rdd.getId();
assertTrue(rddId.contains(requestOperationId));
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(d.getId()));
}

@Test
Expand All @@ -113,9 +113,9 @@ public void testAsyncDependencyCallWithOkHttp3() {
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
RequestData d = getTelemetryDataForType(0, "RequestData");
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
String requestOperationId = d.getId();
String rddId = rdd.getId();
assertTrue(rddId.contains(requestOperationId));
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(d.getId()));
}

@Test
Expand All @@ -125,9 +125,9 @@ public void testAsyncDependencyCallWithOkHttp2() {
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
RequestData d = getTelemetryDataForType(0, "RequestData");
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
String requestOperationId = d.getId();
String rddId = rdd.getId();
assertTrue(rddId.contains(requestOperationId));
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(d.getId()));
}

@Test
Expand All @@ -137,8 +137,8 @@ public void testAsyncDependencyCallWithHttpURLConnection() {
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
RequestData d = getTelemetryDataForType(0, "RequestData");
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
String requestOperationId = d.getId();
String rddId = rdd.getId();
assertTrue(rddId.contains(requestOperationId));
assertEquals("GET /", rdd.getName());
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
assertTrue(rdd.getId().contains(d.getId()));
}
}

0 comments on commit 543043b

Please sign in to comment.