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 http remote dependency capture #1025

Merged
merged 2 commits into from
Aug 21, 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
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()));
}
}