-
Notifications
You must be signed in to change notification settings - Fork 208
Add rate limited sampling smoke tests for ingestion sampling #3731
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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_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.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-ingestion-sampling-disabled.json") | ||
abstract class RateLimitedSamplingIngestionSamplingDisabledTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri(value = "/sampling", callCount = 1000) | ||
void testSampling() throws Exception { | ||
// give some time to collect | ||
Thread.sleep(SECONDS.toMillis(5)); | ||
|
||
List<Envelope> rdEnvelopes = testing.mockedIngestion.getItemsEnvelopeDataType("RequestData"); | ||
|
||
assertThat(rdEnvelopes.size()).isEqualTo(1000); | ||
|
||
for (Envelope rdEnvelope : rdEnvelopes) { | ||
assertThat(rdEnvelope.getSampleRate()).isEqualTo(99.99f); | ||
} | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_21) | ||
static class Tomcat8Java21Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends RateLimitedSamplingIngestionSamplingDisabledTest {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// 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_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.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-ingestion-sampling.json") | ||
abstract class RateLimitedSamplingIngestionSamplingTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri(value = "/sampling", callCount = 1000) | ||
void testSampling() throws Exception { | ||
// give some time to collect | ||
Thread.sleep(SECONDS.toMillis(5)); | ||
|
||
List<Envelope> rdEnvelopes = testing.mockedIngestion.getItemsEnvelopeDataType("RequestData"); | ||
|
||
assertThat(rdEnvelopes.size()).isEqualTo(1000); | ||
|
||
for (Envelope rdEnvelope : rdEnvelopes) { | ||
assertThat(rdEnvelope.getSampleRate()).isNull(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this have a meaningful value when sampling is enabled? Am I missing something here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, this is about ingestion (server-side) sampling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can the name of this test be changed to make this more clear? To my understanding, this test asserts that when rate limited sampler is used, everything is sampled in at 100% & ingestion sampling enabled in json config, then we expect the rate to be null? |
||
} | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_21) | ||
static class Tomcat8Java21Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends RateLimitedSamplingIngestionSamplingTest {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling" : { | ||
"requestsPerSecond": 100000 | ||
}, | ||
"preview": { | ||
"sampling": { | ||
"ingestionSamplingEnabled": false | ||
trask marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling" : { | ||
"requestsPerSecond": 100000 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When sampling is disabled shouldn't this be 100%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC when it's 100 then ingestion sampling will take effect
but then again, I thought ingestion sampling only takes effect when we send no sample rate, so maybe it can be 100, I'll need to re-test this to confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this part of code where sample rate is set to 99.99 when sampler returns 100:
ApplicationInsights-Java/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/sampling/SamplerUtil.java
Line 30 in ab07cc3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trask you may want to put a comment about why you expect this to be 99.99 in the test so folks don't get confused