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
@@ -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;
Expand All @@ -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
* <p>
Expand Down Expand Up @@ -99,9 +100,9 @@ public Set<Class> getIncludedTypes() {

private void setIncludedOrExcludedTypes(String value, Set<Class> 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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
}

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -513,15 +513,15 @@ private void testSampling(TelemetryClient client , List<List<Telemetry>> depende
processor.setSamplingPercentage(String.valueOf(samplingRate));
if (includeTypes != null) {
for (String includeType : includeTypes) {
if (!StringUtils.isNullOrEmpty(includeType)) {
if (!StringUtils.isEmpty(includeType)) {
processor.addToIncludedType(includeType);
}
}
}

if (excludeTypes != null) {
for (String excludeType : excludeTypes) {
if (!StringUtils.isNullOrEmpty(excludeType)) {
if (!StringUtils.isEmpty(excludeType)) {
processor.addToExcludedType(excludeType);
}
}
Expand Down Expand Up @@ -559,15 +559,15 @@ private void testNoSampling(TelemetryClient client , List<List<Telemetry>> depen
processor.setSamplingPercentage(String.valueOf(samplingRate));
if (includeTypes != null) {
for (String includeType : includeTypes) {
if (!StringUtils.isNullOrEmpty(includeType)) {
if (!StringUtils.isEmpty(includeType)) {
processor.addToIncludedType(includeType);
}
}
}

if (excludeTypes != null) {
for (String excludeType : excludeTypes) {
if (!StringUtils.isNullOrEmpty(excludeType)) {
if (!StringUtils.isEmpty(excludeType)) {
processor.addToExcludedType(excludeType);
}
}
Expand Down
25 changes: 11 additions & 14 deletions gradle/provided-configuration.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}