-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable sampling override using thread.id and thread.name (#3285)
- Loading branch information
Showing
6 changed files
with
150 additions
and
6 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
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
58 changes: 58 additions & 0 deletions
58
...okeTest/java/com/microsoft/applicationinsights/smoketest/SamplingOverridesThreadName.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,58 @@ | ||
// 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_19; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_20; | ||
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 org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent("applicationinsights-thread-name.json") | ||
abstract class SamplingOverridesThreadName { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri(value = "/thread-name", callCount = 100) | ||
void testSampling() throws Exception { | ||
assertThat(testing.mockedIngestion.getCountForType("RequestData")).isZero(); | ||
assertThat(testing.mockedIngestion.getCountForType("MessageData")).isZero(); | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(TOMCAT_8_JAVA_19) | ||
static class Tomcat8Java19Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(TOMCAT_8_JAVA_20) | ||
static class Tomcat8Java20Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends SamplingOverridesThreadName {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends SamplingOverridesThreadName {} | ||
} |
75 changes: 75 additions & 0 deletions
75
...tests/apps/SamplingOverrides/src/smokeTest/resources/applicationinsights-thread-name.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,75 @@ | ||
{ | ||
"connectionString": "InstrumentationKey=12345678-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://host.testcontainers.internal:6060/", | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling": { | ||
"percentage": 50 | ||
}, | ||
"preview": { | ||
"sampling": { | ||
"overrides": [ | ||
{ | ||
"telemetryType": "request", | ||
"attributes": [ | ||
{ | ||
"key": "thread.name", | ||
"value": "http-nio-.*", | ||
"matchType": "regexp" | ||
}, | ||
{ | ||
"key": "http.target", | ||
"value": "/SamplingOverrides/health-check", | ||
"matchType": "strict" | ||
} | ||
], | ||
"percentage": 100 | ||
}, | ||
{ | ||
"telemetryType": "request", | ||
"attributes": [ | ||
{ | ||
"key": "thread.name", | ||
"value": "http-nio-.*", | ||
"matchType": "regexp" | ||
}, | ||
{ | ||
"key": "http.target", | ||
"value": "/SamplingOverrides/", | ||
"matchType": "strict" | ||
} | ||
], | ||
"percentage": 100 | ||
}, | ||
{ | ||
"telemetryType": "request", | ||
"attributes": [ | ||
{ | ||
"key": "thread.name", | ||
"value": "http-nio-.*", | ||
"matchType": "regexp" | ||
}, | ||
{ | ||
"key": "http.target", | ||
"value": "/SamplingOverrides/thread-name", | ||
"matchType": "strict" | ||
} | ||
], | ||
"percentage": 0 | ||
}, | ||
{ | ||
"telemetryType": "trace", | ||
"attributes": [ | ||
{ | ||
"key": "thread.name", | ||
"value": "http-nio-.*", | ||
"matchType": "regexp" | ||
} | ||
], | ||
"percentage": 0 | ||
} | ||
] | ||
} | ||
} | ||
} |