Skip to content

Commit 543043b

Browse files
authored
Merge pull request #1025 from microsoft/fix-http-remote-dependency-capture
Fix http remote dependency capture
2 parents 5814fca + 6568775 commit 543043b

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

agent/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ plugins {
2626
apply from: "$buildScriptsDir/common-java.gradle"
2727
apply from: "$buildScriptsDir/publishing.gradle"
2828

29-
def instrumentationVersion = '0.14.2'
29+
def instrumentationVersion = '0.14.3'
3030

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

agent/src/main/java/com/microsoft/applicationinsights/agent/internal/MainEntryPoint.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ private static void start(Instrumentation instrumentation, File agentJarFile) th
9999
AIAgentXmlLoader.getInstrumentationConfig(builtInInstrumentation));
100100

101101
EngineModule.createWithSomeDefaults(instrumentation, tmpDir, Global.getThreadContextThreadLocal(),
102-
instrumentationDescriptors, configServiceFactory, new AgentImpl(),
102+
instrumentationDescriptors, configServiceFactory, new AgentImpl(), false,
103+
Collections.singletonList("com.microsoft.applicationinsights.agent"),
103104
Collections.singletonList("com.microsoft.applicationinsights.agent"), agentJarFile);
104105
}
105106
}

agent/src/main/java/com/microsoft/applicationinsights/agent/internal/model/OutgoingSpanImpl.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.net.URISyntaxException;
2626
import java.util.Map;
2727

28+
import com.google.common.base.Strings;
2829
import com.microsoft.applicationinsights.agent.internal.sdk.SdkBridge;
2930
import com.microsoft.applicationinsights.agent.internal.sdk.SdkBridge.ExceptionTelemetry;
3031
import com.microsoft.applicationinsights.agent.internal.sdk.SdkBridge.RemoteDependencyTelemetry;
@@ -157,7 +158,12 @@ private void endInternal() {
157158
} else {
158159
target = sdkBridge.generateChildDependencyTarget(requestContext, Global.isOutboundW3CEnabled());
159160
}
160-
telemetry.setName(method + " " + uriObject.getPath());
161+
String path = uriObject.getPath();
162+
if (Strings.isNullOrEmpty(path)) {
163+
telemetry.setName(method + " /");
164+
} else {
165+
telemetry.setName(method + " " + path);
166+
}
161167
if (target != null && !target.isEmpty()) {
162168
// AI correlation expects target to be of this format.
163169
telemetry.setTarget(createTarget(uriObject, target));

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ archivesBaseName = 'applicationinsights-core'
109109

110110
dependencies {
111111
compileOnly (project(':agent')) { transitive = false }
112-
compileOnly ([group: 'org.glowroot.instrumentation', name: 'instrumentation-api', version: '0.14.2']) { transitive = false }
112+
compileOnly ([group: 'org.glowroot.instrumentation', name: 'instrumentation-api', version: '0.14.3']) { transitive = false }
113113
compile(project(':ApplicationInsightsInternalLogger'))
114114
compile ([group: 'eu.infomas', name: 'annotation-detector', version: '3.0.5'])
115115
compile ([group: 'commons-io', name: 'commons-io', version: '2.6' ])

test/smoke/testApps/SpringBootTest/src/smokeTest/java/com/springbootstartertest/smoketest/SpringbootSmokeTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public void testAsyncDependencyCallWithApacheHttpClient4() {
8989
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
9090
RequestData d = getTelemetryDataForType(0, "RequestData");
9191
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
92-
String requestOperationId = d.getId();
93-
String rddId = rdd.getId();
94-
assertTrue(rddId.contains(requestOperationId));
92+
assertEquals("GET /", rdd.getName());
93+
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
94+
assertTrue(rdd.getId().contains(d.getId()));
9595
}
9696

9797
@Test
@@ -101,9 +101,9 @@ public void testAsyncDependencyCallWithApacheHttpClient3() {
101101
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
102102
RequestData d = getTelemetryDataForType(0, "RequestData");
103103
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
104-
String requestOperationId = d.getId();
105-
String rddId = rdd.getId();
106-
assertTrue(rddId.contains(requestOperationId));
104+
assertEquals("GET /", rdd.getName());
105+
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
106+
assertTrue(rdd.getId().contains(d.getId()));
107107
}
108108

109109
@Test
@@ -113,9 +113,9 @@ public void testAsyncDependencyCallWithOkHttp3() {
113113
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
114114
RequestData d = getTelemetryDataForType(0, "RequestData");
115115
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
116-
String requestOperationId = d.getId();
117-
String rddId = rdd.getId();
118-
assertTrue(rddId.contains(requestOperationId));
116+
assertEquals("GET /", rdd.getName());
117+
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
118+
assertTrue(rdd.getId().contains(d.getId()));
119119
}
120120

121121
@Test
@@ -125,9 +125,9 @@ public void testAsyncDependencyCallWithOkHttp2() {
125125
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
126126
RequestData d = getTelemetryDataForType(0, "RequestData");
127127
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
128-
String requestOperationId = d.getId();
129-
String rddId = rdd.getId();
130-
assertTrue(rddId.contains(requestOperationId));
128+
assertEquals("GET /", rdd.getName());
129+
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
130+
assertTrue(rdd.getId().contains(d.getId()));
131131
}
132132

133133
@Test
@@ -137,8 +137,8 @@ public void testAsyncDependencyCallWithHttpURLConnection() {
137137
assertEquals(1, mockedIngestion.getCountForType("RemoteDependencyData"));
138138
RequestData d = getTelemetryDataForType(0, "RequestData");
139139
RemoteDependencyData rdd = getTelemetryDataForType(0, "RemoteDependencyData");
140-
String requestOperationId = d.getId();
141-
String rddId = rdd.getId();
142-
assertTrue(rddId.contains(requestOperationId));
140+
assertEquals("GET /", rdd.getName());
141+
assertEquals("www.bing.com:-1 | www.bing.com", rdd.getTarget());
142+
assertTrue(rdd.getId().contains(d.getId()));
143143
}
144144
}

0 commit comments

Comments
 (0)