From 1b6b76e86f4131c767fa25a34000e5ba76d95eed Mon Sep 17 00:00:00 2001 From: littleaj <1690572+littleaj@users.noreply.github.com> Date: Thu, 7 Dec 2017 11:42:14 -0800 Subject: [PATCH 1/3] reworked 'provided' configuration so it works properly (should not be repackaged in our jars) --- gradle/provided-configuration.gradle | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gradle/provided-configuration.gradle b/gradle/provided-configuration.gradle index 4aa7fe351b7..a87e81bc3e8 100644 --- a/gradle/provided-configuration.gradle +++ b/gradle/provided-configuration.gradle @@ -19,21 +19,18 @@ * DEALINGS IN THE SOFTWARE. */ -// Adding the "provided" configuration - -ext { - PROVIDED_CONFIGURATION_NAME = "provided" +// Defines the "provided" configuration for dependencies that the client is responsible for including on the classpath +configurations { + provided } -configurations { - provided { - // Remove the provided dependencies from the default configuration so - // these dependencies won't be derived by projects that has a dependency on - // the project using the provided scope - dependencies.all { dep -> - configurations.default.exclude group: dep.group, module: dep.name - } +sourceSets { + main { + compileClasspath += configurations.provided + runtimeClasspath += configurations.provided + } + test { + compileClasspath += configurations.provided + runtimeClasspath += configurations.provided } - compile.extendsFrom provided } - From d005fc5abe6861936c37d75386d39d6def2c4001 Mon Sep 17 00:00:00 2001 From: littleaj <1690572+littleaj@users.noreply.github.com> Date: Thu, 7 Dec 2017 11:44:15 -0800 Subject: [PATCH 2/3] removed references to the agent package (previously incorrectly included in the jar) --- .../FixedRateSamplingTelemetryProcessor.java | 7 ++++--- .../channel/samplingV2/SamplingScoreGeneratorV2.java | 6 +++--- .../FixedRateSamplingTelemetryProcessorTest.java | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessor.java b/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessor.java index 9b556860df9..0e293672515 100644 --- a/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessor.java +++ b/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessor.java @@ -1,6 +1,5 @@ package com.microsoft.applicationinsights.internal.channel.samplingV2; -import com.microsoft.applicationinsights.agent.internal.common.StringUtils; import com.microsoft.applicationinsights.extensibility.TelemetryProcessor; import com.microsoft.applicationinsights.internal.annotation.BuiltInProcessor; import com.microsoft.applicationinsights.internal.logger.InternalLogger; @@ -12,6 +11,8 @@ import java.util.Map; import java.util.Set; +import org.apache.commons.lang3.StringUtils; + /** * This processor is used to Perform Sampling on User specified sampling rate *

@@ -99,9 +100,9 @@ public Set getIncludedTypes() { private void setIncludedOrExcludedTypes(String value, Set typeSet) { - if (!StringUtils.isNullOrEmpty(value)) { + if (!StringUtils.isEmpty(value)) { value = value.trim(); - if (!StringUtils.isNullOrEmpty(value) && allowedTypes.containsKey(value)) { + if (!StringUtils.isEmpty(value) && allowedTypes.containsKey(value)) { typeSet.add(allowedTypes.get(value)); } else { InternalLogger.INSTANCE.error("Item is either not allowed to sample or is empty"); diff --git a/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/SamplingScoreGeneratorV2.java b/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/SamplingScoreGeneratorV2.java index 11c4be0d1b5..7f9b35e065c 100644 --- a/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/SamplingScoreGeneratorV2.java +++ b/core/src/main/java/com/microsoft/applicationinsights/internal/channel/samplingV2/SamplingScoreGeneratorV2.java @@ -1,9 +1,9 @@ package com.microsoft.applicationinsights.internal.channel.samplingV2; -import com.microsoft.applicationinsights.agent.internal.common.StringUtils; import com.microsoft.applicationinsights.telemetry.Telemetry; import java.util.Random; +import org.apache.commons.lang3.StringUtils; /** * Created by Dhaval Doshi Oct 2017 @@ -24,7 +24,7 @@ public static double getSamplingScore(Telemetry telemetry) { double samplingScore = 0.0; - if (!StringUtils.isNullOrEmpty(telemetry.getContext().getOperation().getId())) { + if (!StringUtils.isEmpty(telemetry.getContext().getOperation().getId())) { samplingScore = ((double) getSamplingHashCode(telemetry.getContext().getOperation().getId()) / Integer.MAX_VALUE); } @@ -37,7 +37,7 @@ public static double getSamplingScore(Telemetry telemetry) { } static int getSamplingHashCode(String input) { - if (StringUtils.isNullOrEmpty(input)) { + if (StringUtils.isEmpty(input)) { return 0; } diff --git a/core/src/test/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessorTest.java b/core/src/test/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessorTest.java index da96d3720e9..dce24521527 100644 --- a/core/src/test/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessorTest.java +++ b/core/src/test/java/com/microsoft/applicationinsights/internal/channel/samplingV2/FixedRateSamplingTelemetryProcessorTest.java @@ -3,13 +3,13 @@ import com.microsoft.applicationinsights.TelemetryClient; import com.microsoft.applicationinsights.TelemetryConfiguration; import com.microsoft.applicationinsights.TestFramework.StubTelemetryChannel; -import com.microsoft.applicationinsights.agent.internal.common.StringUtils; import com.microsoft.applicationinsights.extensibility.TelemetryProcessor; import com.microsoft.applicationinsights.telemetry.PageViewTelemetry; import com.microsoft.applicationinsights.telemetry.RemoteDependencyTelemetry; import com.microsoft.applicationinsights.telemetry.RequestTelemetry; import com.microsoft.applicationinsights.telemetry.SupportSampling; import com.microsoft.applicationinsights.telemetry.Telemetry; +import org.apache.commons.lang3.StringUtils; import org.junit.Assert; import org.junit.Test; @@ -513,7 +513,7 @@ private void testSampling(TelemetryClient client , List> depende processor.setSamplingPercentage(String.valueOf(samplingRate)); if (includeTypes != null) { for (String includeType : includeTypes) { - if (!StringUtils.isNullOrEmpty(includeType)) { + if (!StringUtils.isEmpty(includeType)) { processor.addToIncludedType(includeType); } } @@ -521,7 +521,7 @@ private void testSampling(TelemetryClient client , List> depende if (excludeTypes != null) { for (String excludeType : excludeTypes) { - if (!StringUtils.isNullOrEmpty(excludeType)) { + if (!StringUtils.isEmpty(excludeType)) { processor.addToExcludedType(excludeType); } } @@ -559,7 +559,7 @@ private void testNoSampling(TelemetryClient client , List> depen processor.setSamplingPercentage(String.valueOf(samplingRate)); if (includeTypes != null) { for (String includeType : includeTypes) { - if (!StringUtils.isNullOrEmpty(includeType)) { + if (!StringUtils.isEmpty(includeType)) { processor.addToIncludedType(includeType); } } @@ -567,7 +567,7 @@ private void testNoSampling(TelemetryClient client , List> depen if (excludeTypes != null) { for (String excludeType : excludeTypes) { - if (!StringUtils.isNullOrEmpty(excludeType)) { + if (!StringUtils.isEmpty(excludeType)) { processor.addToExcludedType(excludeType); } } From fa63a1844ff4deee576a98bdd2109a90d02a384c Mon Sep 17 00:00:00 2001 From: littleaj <1690572+littleaj@users.noreply.github.com> Date: Thu, 7 Dec 2017 11:44:46 -0800 Subject: [PATCH 3/3] reclassified dependency only used in tests --- web/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web/build.gradle b/web/build.gradle index d113d68c398..bc7c8cba560 100644 --- a/web/build.gradle +++ b/web/build.gradle @@ -32,7 +32,6 @@ dependencies { provided (project(':agent')) { transitive = false } compile (project(':core')) { transitive = false } compile ([group: 'org.apache.commons', name: 'commons-lang3', version: '3.7']) - compile ([group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3']) provided 'com.opensymphony:xwork:2.0.4' // Struts 2 provided 'org.springframework:spring-webmvc:3.1.0.RELEASE' provided group: 'javax.servlet', name: 'servlet-api', version: '2.5' @@ -45,11 +44,11 @@ dependencies { testCompile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.1' testCompile group: 'org.json', name:'json', version:'20090211' testCompile group: 'com.microsoft.azure', name: 'azure-storage', version: '2.1.0' + testCompile ([group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.3']) } shadowJar { classifier='' - relocate 'org.apache.http', 'com.microsoft.applicationinsights.web.dependencies.http' relocate 'org.apache.commons', 'com.microsoft.applicationinsights.web.dependencies.apachecommons' }