-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce explicit option for disabling ingestion sampling
- Loading branch information
Showing
9 changed files
with
128 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
...g/src/main/java/com/microsoft/applicationinsights/smoketestapp/SimpleSamplingServlet.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...c/smokeTest/java/com/microsoft/applicationinsights/smoketest/NoIngestionSamplingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketest; | ||
|
||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_17; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_21; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_21_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; | ||
import static java.util.concurrent.TimeUnit.NANOSECONDS; | ||
import static java.util.concurrent.TimeUnit.SECONDS; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent("applicationinsights-no-ingestion-sampling.json") | ||
abstract class NoIngestionSamplingTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri(value = "/simple", callCount = 100) | ||
void testNoIngestionSampling() throws Exception { | ||
long start = System.nanoTime(); | ||
while (testing.mockedIngestion.getCountForType("RequestData") < 100 | ||
&& NANOSECONDS.toSeconds(System.nanoTime() - start) < 10) { | ||
// just wait and do nothing | ||
} | ||
Thread.sleep(SECONDS.toMillis(10)); | ||
|
||
assertThat(testing.mockedIngestion.getCountForType("RequestData")).isEqualTo(100); | ||
|
||
List<Envelope> requestEnvelopes = | ||
testing.mockedIngestion.getItemsEnvelopeDataType("RequestData"); | ||
assertThat(requestEnvelopes.size()).isEqualTo(100); | ||
List<Envelope> eventEnvelopes = testing.mockedIngestion.getItemsEnvelopeDataType("EventData"); | ||
assertThat(eventEnvelopes.size()).isEqualTo(100); | ||
List<Envelope> messageEnvelopes = | ||
testing.mockedIngestion.getItemsEnvelopeDataType("MessageData"); | ||
assertThat(messageEnvelopes.size()).isEqualTo(100); | ||
|
||
for (Envelope requestEnvelope : requestEnvelopes) { | ||
assertThat(requestEnvelope.getSampleRate()).isEqualTo(100); | ||
} | ||
for (Envelope eventEnvelope : eventEnvelopes) { | ||
assertThat(eventEnvelope.getSampleRate()).isEqualTo(100); | ||
} | ||
for (Envelope messageEnvelope : messageEnvelopes) { | ||
assertThat(messageEnvelope.getSampleRate()).isEqualTo(100); | ||
} | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_21) | ||
static class Tomcat8Java21Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_21_OPENJ9) | ||
static class Tomcat8Java21OpenJ9Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends NoIngestionSamplingTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends NoIngestionSamplingTest {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...ests/apps/Sampling/src/smokeTest/resources/applicationinsights-no-ingestion-sampling.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling": { | ||
"percentage": 100, | ||
"ingestion": false | ||
} | ||
} |