Skip to content
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 @@ -236,14 +236,14 @@ protected void byteCodeForMethodExit(int opcode) {

mv.visitFieldInsn(Opcodes.GETSTATIC, internalName, "INSTANCE", "L" + internalName + ";");

mv.visitLdcInsn(getMethodName());
mv.visitVarInsn(ALOAD, methodLocal);
mv.visitLdcInsn(getMethodName()); // identifier
mv.visitVarInsn(ALOAD, methodLocal); // method
//Path is populated in CoreAgentNotificationHandler httpMethodFinished() method
mv.visitVarInsn(ALOAD, childIdLocal);
mv.visitVarInsn(ALOAD, uriLocal);
mv.visitVarInsn(ALOAD, targetLocal); //using derived target
mv.visitVarInsn(ILOAD, statusCodeLocal);
mv.visitVarInsn(LLOAD, deltaInNS);
mv.visitVarInsn(ALOAD, childIdLocal); // correlationId
mv.visitVarInsn(ALOAD, uriLocal); // uri
mv.visitVarInsn(ALOAD, targetLocal); // target; using derived target
mv.visitVarInsn(ILOAD, statusCodeLocal); // result
mv.visitVarInsn(LLOAD, deltaInNS); // delta
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, internalName, FINISH_DETECT_METHOD_NAME, FINISH_METHOD_RETURN_SIGNATURE, false);

//skip the following instructions
Expand Down
12 changes: 8 additions & 4 deletions azure-application-insights-spring-boot-starter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,16 @@ dependencies {
compile(project(':web'))
compile(project(':ApplicationInsightsInternalLogger'))
compile ([group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'])
provided('org.springframework.boot:spring-boot:1.5.9.RELEASE')
provided('org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE')
provided('org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE')
provided('org.springframework.boot:spring-boot-configuration-processor:1.5.9.RELEASE')
compileOnly('org.springframework.boot:spring-boot:1.5.9.RELEASE')
compileOnly('org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE')
compileOnly('org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE')
compileOnly('org.springframework.boot:spring-boot-configuration-processor:1.5.9.RELEASE')
testCompile('junit:junit:4.12')
testCompile('org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE')
testCompile('org.springframework.boot:spring-boot:1.5.9.RELEASE')
testCompile('org.springframework.boot:spring-boot-autoconfigure:1.5.9.RELEASE')
testCompile('org.springframework.boot:spring-boot-starter-web:1.5.9.RELEASE')
testCompile('org.springframework.boot:spring-boot-configuration-processor:1.5.9.RELEASE')
testCompile('org.assertj:assertj-core:2.6.0')
}

Expand Down
20 changes: 2 additions & 18 deletions collectd/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,12 @@ if (!collectDLibPath.exists()) {

archivesBaseName = 'applicationinsights-collectd'

// Defining a local provided configuration WITHOUT having it extending the compile configuration (like done in
// the provided-configuration.gradle file).
// This is a work-around so the collectd library (org.collectd.api) will be excluded from the generated jar
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
test {
compileClasspath += configurations.provided
runtimeClasspath += configurations.provided
}
}

dependencies {
compile project(':core')
provided files(collectDLibPath)
compileOnly files(collectDLibPath)
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile files(collectDLibPath)
}

// Building the shadow (fat) jar after compiling sources.
Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import com.microsoft.applicationinsights.build.tasks.PropsFileGen
archivesBaseName = 'applicationinsights-core'

dependencies {
provided (project(':agent')) { transitive = false }
compileOnly (project(':agent')) { 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 All @@ -119,6 +119,7 @@ dependencies {
compile ([group: 'io.grpc', name: 'grpc-stub', version: '1.16.1'])
compile ([group: 'io.grpc', name: 'grpc-protobuf', version: '1.16.1'])
runtime ([group: 'io.grpc', name: 'grpc-netty-shaded', version: '1.16.1'])
testCompile (project(':agent')) { transitive = false }
testCompile group: 'org.hamcrest', name:'hamcrest-core', version:'1.3'
testCompile group: 'org.hamcrest', name:'hamcrest-library', version:'1.3'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public Optional<Transmission> serialize(Collection<String> telemetries) {

private boolean compress(GZIPOutputStream zipStream, Collection<String> telemetries) throws IOException {
int counter = 0;
StringWriter writer = new StringWriter();
JsonTelemetryDataSerializer jsonWriter = new JsonTelemetryDataSerializer(writer);

// The format is:
// 1. Separate each Telemetry by newline
Expand All @@ -115,11 +113,6 @@ private boolean compress(GZIPOutputStream zipStream, Collection<String> telemetr
} catch (Exception e) {
InternalLogger.INSTANCE.error("Failed to serialize , exception: %s", e.toString());
}

if (counter < telemetries.size()) {
writer.getBuffer().setLength(0);
jsonWriter.reset(writer);
}
}

return counter > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void backoff() {
public void clearBackoff() {
policyState.setCurrentState(TransmissionPolicy.UNBLOCKED);
backoffManager.onDoneSending();
InternalLogger.INSTANCE.info("Backoff has been reset.");
// InternalLogger.INSTANCE.info("Backoff has been reset.");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ private static void loadNativeLibrary() throws IOException {
}

private static void extractToLocalFolder(File dllOnDisk, String libraryToLoad) throws IOException {
InputStream in = JniPCConnector.class.getClassLoader().getResourceAsStream(libraryToLoad);
ClassLoader classLoader = JniPCConnector.class.getClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}
InputStream in = classLoader.getResourceAsStream(libraryToLoad);
if (in == null) {
throw new RuntimeException(String.format("Failed to find '%s' in jar", libraryToLoad));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public static Properties getProperties(String name) throws IOException
{
Properties props = new Properties();
ClassLoader classLoader = PropertyHelper.class.getClassLoader();
if (classLoader == null) {
classLoader = ClassLoader.getSystemClassLoader();
}

// Look in the class loader's default location.
InputStream inputStream = classLoader.getResourceAsStream(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public final class ExceptionTelemetry extends BaseSampleSourceTelemetry<Exceptio
public static final String BASE_TYPE = "ExceptionData";


private ExceptionTelemetry() {
public ExceptionTelemetry() {
super();
data = new ExceptionData();
initialize(data.getProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,26 +243,22 @@ public <T extends JsonSerializable> void write(String name, T value) throws IOEx

public <T> void write(String name, Map<String, T> map) throws IOException {

if (map == null) {
if (map == null || map.isEmpty()) {
return;
}

writeName(name);
try {
if (map.size() < 1) {
out.write("null");
} else {
out.write(JSON_START_OBJECT);

separator = "";
for (Map.Entry<String, T> entry : map.entrySet()) {
writeName(sanitizeKey(entry.getKey()));
write(entry.getValue());
separator = JSON_SEPARATOR;
}
out.write(JSON_START_OBJECT);

out.write(JSON_CLOSE_OBJECT);
separator = "";
for (Map.Entry<String, T> entry : map.entrySet()) {
writeName(sanitizeKey(entry.getKey()));
write(entry.getValue());
separator = JSON_SEPARATOR;
}

out.write(JSON_CLOSE_OBJECT);
} finally {
separator = JSON_SEPARATOR;
}
Expand Down Expand Up @@ -367,9 +363,6 @@ private String sanitizeStringForJSON(String text, int maxLength) {
else if(curr == '\\'){
result.append("\\\\");
}
else if(curr == '/'){
result.append("\\/");
}
else if(curr == '\b'){
result.append("\\b");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private static void verifyJson(
telemetry.serialize(jsonWriter);
jsonWriter.close();
String asJson = writer.toString();
String expectedPerformanceDataPartFormat = "\"baseData\":{\"ver\":2,\"categoryName\":\"%s\",\"counterName\":\"%s\",\"instanceName\":\"%s\",\"value\":%.1f,\"properties\":null}}}";
String expectedPerformanceDataPartFormat = "\"baseData\":{\"ver\":2,\"categoryName\":\"%s\",\"counterName\":\"%s\",\"instanceName\":\"%s\",\"value\":%.1f}}}";
String expected = String.format(expectedPerformanceDataPartFormat, expectedCategory, expectedCounter, expectedInstance, expectedValue);
assertTrue(asJson.indexOf(expected) != -1);
}
Expand Down
25 changes: 0 additions & 25 deletions distributions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,5 @@ dependencies {
compile project(':logging:logback')
}

gradle.projectsEvaluated {
project.configurations.compile.dependencies.each { dep ->
ConfigurationContainer cc = dep.dependencyProject.configurations

def providedConfiguration = cc.findByName("provided")
if (providedConfiguration != null) {
providedConfiguration.dependencies.each { provDep ->
shadowJar {
dependencies {
if (provDep instanceof ProjectDependency) {
def projPath = provDep.dependencyProject.path
logger.info "Excluding provided project dependency for project $projPath"
exclude(project(projPath))
} else if (provDep instanceof ExternalModuleDependency) {
def gav = "$provDep.group:$provDep.name:$provDep.version"
logger.info "Excluding provided external dependency for artifact $gav"
exclude(dependency(gav))
}
}
}
}
}
}
}

// Building the shadow (fat) jar after compiling sources.
shadowJar.dependsOn assemble
36 changes: 0 additions & 36 deletions gradle/provided-configuration.gradle

This file was deleted.

5 changes: 1 addition & 4 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

apply plugin: 'maven'
apply from: "$buildScriptsDir/provided-configuration.gradle"

ext {
projectPomName = ""
Expand Down Expand Up @@ -131,8 +130,6 @@ def updatePomWithGeneralProjectInformation(pomObject) {
}
}

scopeMappings.addMapping(MavenPlugin.PROVIDED_COMPILE_PRIORITY, configurations.getByName("provided"), Conf2ScopeMappingContainer.PROVIDED)

withXml {
// Append license text to pom.xml
def pomText = asString()
Expand All @@ -150,7 +147,7 @@ def updatePomWithGeneralProjectInformation(pomObject) {

javadoc {
source = sourceSets.main.allJava
classpath = configurations.compile + configurations.provided
classpath = configurations.compile
}

task prepareSourcesArchive(type: Jar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void execOnContainer(String id, String cmd, String... args) throws IOExce
}
}

private static void waitAndCheckCodeForProcess(Process p, long timeout, TimeUnit unit, String actionName) throws IOException, InterruptedException {
private void waitAndCheckCodeForProcess(Process p, long timeout, TimeUnit unit, String actionName) throws IOException, InterruptedException {
waitForProcessToReturn(p, timeout, unit, actionName);
if (p.exitValue() != 0) {
flushStdout(p);
Expand All @@ -164,9 +164,11 @@ private static void waitAndCheckCodeForProcess(Process p, long timeout, TimeUnit
}
}

private static void waitForProcessToReturn(Process p, long timeout, TimeUnit unit, String actionName) throws IOException, InterruptedException {
private void waitForProcessToReturn(Process p, long timeout, TimeUnit unit, String actionName) throws IOException, InterruptedException {
if (!p.waitFor(timeout, unit)) {
p.destroyForcibly();
String containerId = getFirstLineOfProcessOutput(p);
printContainerLogs(containerId);
p.destroyForcibly();
flushStdout(p);
throw new TimeoutException(
Strings.isNullOrEmpty(actionName) ? "process" : actionName,
Expand Down
2 changes: 2 additions & 0 deletions test/smoke/testApps/CoreAndFilter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dependencies {

smokeTestCompile 'com.google.guava:guava:23.0'
testCompile 'com.google.guava:guava:23.0' // VSCODE intellisense bug workaround

testCompile group:'org.hamcrest', name:'hamcrest-library', version:'1.3'
}

compileJava.sourceCompatibility = 1.7
Expand Down
2 changes: 2 additions & 0 deletions test/smoke/testApps/FixedRateSampling/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies {
smokeTestCompile 'com.google.guava:guava:23.0'

testCompile 'com.google.guava:guava:23.0' // VSCODE intellisense bug workaround

testCompile group:'org.hamcrest', name:'hamcrest-library', version:'1.3'
}

compileJava.sourceCompatibility = 1.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public void resultCodeTest() throws Exception {
throw new ServletException("This is an exception");
}

@Async
@GetMapping("/asyncDependencyCall")
public AsyncResult<Integer> asyncDependencyCall() throws IOException {
String url = "https://www.bing.com";
Expand Down
15 changes: 10 additions & 5 deletions web/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ apply from: "$buildScriptsDir/publishing.gradle"
archivesBaseName = 'applicationinsights-web'

dependencies {
provided (project(':agent')) { transitive = false }
compileOnly (project(':agent')) { transitive = false }
compile (project(':core')) { transitive = false }
compile(project(':ApplicationInsightsInternalLogger'))
compile ([group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'])
compile ([group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3'])
compile ([group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.3'])
provided 'com.opensymphony:xwork:2.0.4' // Struts 2
provided 'org.springframework:spring-webmvc:3.1.0.RELEASE'
provided group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
provided group: 'javax.enterprise', name: 'cdi-api', version: '1.1' // Java EE
compileOnly 'com.opensymphony:xwork:2.0.4' // Struts 2
compileOnly 'org.springframework:spring-webmvc:3.1.0.RELEASE'
compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
compileOnly group: 'javax.enterprise', name: 'cdi-api', version: '1.1' // Java EE
testCompile (project(':agent')) { transitive = false }
testCompile 'com.opensymphony:xwork:2.0.4' // Struts 2
testCompile 'org.springframework:spring-webmvc:3.1.0.RELEASE'
testCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
testCompile group: 'javax.enterprise', name: 'cdi-api', version: '1.1' // Java EE
testCompile group: 'org.hamcrest', name:'hamcrest-core', version:'1.3'
testCompile group: 'org.hamcrest', name:'hamcrest-library', version:'1.3'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ protected void onInitializeTelemetry(Telemetry telemetry) {
session.setId(requestSessionContext.getId());

Boolean isFirst = requestSessionContext.getIsFirst();
session.setIsFirst(isFirst != null ? isFirst : false);
if (isFirst != null) {
session.setIsFirst(isFirst);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ private void testNoSessionCookie(Boolean isFirstValue) {
sessionTelemetryInitializer.onInitializeTelemetry(telemetry);

Assert.assertNull(telemetry.getContext().getSession().getId());
Assert.assertFalse(telemetry.getContext().getSession().getIsFirst());
Assert.assertEquals(telemetry.getContext().getSession().getIsFirst(), isFirstValue);
}
}