Skip to content
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

Snippet injection Test update #3132

Merged
merged 43 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
27e5926
snippet injection
siyuniu-ms Feb 3, 2023
58decf7
Update build.gradle.kts
siyuniu-ms Feb 3, 2023
1e32653
remove lockerfile
siyuniu-ms Feb 3, 2023
a88c0f6
Revert "remove lockerfile"
siyuniu-ms Feb 3, 2023
91b91e0
Revert "Update build.gradle.kts"
siyuniu-ms Feb 3, 2023
d199d7f
Revert "snippet injection"
siyuniu-ms Feb 3, 2023
4a44816
Revert "Revert "remove lockerfile""
siyuniu-ms Feb 3, 2023
b2223d5
Update SnippetConfiguration.java
siyuniu-ms Feb 3, 2023
d63910f
Merge remote-tracking branch 'origin/main' into snippet-injection
siyuniu-ms Feb 14, 2023
21c7dec
add smoke test
siyuniu-ms Feb 23, 2023
bfeb028
Merge branch 'main' into snippet-injection
siyuniu-ms Feb 23, 2023
b0a47f2
test only
siyuniu-ms Feb 28, 2023
b035a03
Merge branch 'main' into snippet-injection
siyuniu-ms Jun 12, 2023
4e83a71
smoke test
siyuniu-ms Jun 12, 2023
ed86694
update
siyuniu-ms Jun 12, 2023
c7f3397
Merge branch 'fixSnippet' into snippet-injection
siyuniu-ms Jun 12, 2023
f36236a
change the string
siyuniu-ms Jun 12, 2023
36e830a
extract
siyuniu-ms Jun 12, 2023
4a03bc4
Update SnippetConfigurationTest.java
siyuniu-ms Jun 12, 2023
f70b72d
Update SnippetConfiguration.java
siyuniu-ms Jun 12, 2023
9063e21
Merge branch 'fixSnippet' into snippet-injection
siyuniu-ms Jun 12, 2023
8b57c1d
update \n
siyuniu-ms Jun 12, 2023
118d939
Merge branch 'fixSnippet' into snippet-injection
siyuniu-ms Jun 12, 2023
776e6b3
smoke test passed
siyuniu-ms Jun 13, 2023
8fbff6c
Merge branch 'main' into snippet-injection
siyuniu-ms Jun 13, 2023
7755065
Update applicationinsights.json
siyuniu-ms Jun 13, 2023
ffff9f5
Update SnippetInjectionTest.java
siyuniu-ms Jun 13, 2023
2aad092
Update build.gradle.kts
siyuniu-ms Jun 14, 2023
75b297b
Update build.gradle.kts
siyuniu-ms Jun 14, 2023
4c130e6
Merge branch 'main' into snippet-injection
siyuniu-ms Jun 14, 2023
492ff0f
be more specific
siyuniu-ms Jun 15, 2023
75bfe07
Merge branch 'main' into snippet-injection
siyuniu-ms Jun 15, 2023
675c971
update
siyuniu-ms Jun 15, 2023
5b22084
sprint boot auto called?
siyuniu-ms Jun 15, 2023
86e8444
Create applicationinsights.json
siyuniu-ms Jun 15, 2023
5ac4619
Update applicationinsights.json
siyuniu-ms Jun 15, 2023
cb9a655
update config name
siyuniu-ms Jun 16, 2023
9c7c81b
update relevant name
siyuniu-ms Jun 16, 2023
65a3b0d
Update agent/agent-tooling/src/main/java/com/microsoft/applicationins…
siyuniu-ms Jun 16, 2023
e2c7f6e
Update agent/agent-tooling/src/main/java/com/microsoft/applicationins…
siyuniu-ms Jun 16, 2023
1fff3eb
Update browser-sdk-loader-snippet.txt
siyuniu-ms Jun 16, 2023
7d20ba2
Update Feature.java
siyuniu-ms Jun 16, 2023
c943e74
Update settings.gradle.kts
siyuniu-ms Jun 16, 2023
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
Expand Up @@ -317,7 +317,7 @@ public static class PreviewConfiguration {
public boolean disablePropagation;
public boolean captureHttpServer4xxAsError = true;

public JavaScriptSnippet javaScriptSnippet = new JavaScriptSnippet();
public BrowserSdkLoader browserSdkLoader = new BrowserSdkLoader();

// LoggingLevel is no longer sent by default since 3.3.0, since the data is already available
// under SeverityLevel. This configuration is provided as a temporary measure for customers
Expand Down Expand Up @@ -584,7 +584,7 @@ public static class EnabledByDefaultInstrumentation {
public boolean enabled = true;
}

public static class JavaScriptSnippet {
public static class BrowserSdkLoader {
public boolean enabled;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SnippetConfiguration {
// visible for testing
static String readSnippet() {
ClassLoader classLoader = SnippetConfiguration.class.getClassLoader();
String resourceName = "javascript-snippet.txt";
String resourceName = "browser-sdk-loader-snippet.txt";
InputStream inputStream = classLoader.getResourceAsStream(resourceName);
if (inputStream == null) {
LOGGER.error("Resource not found: " + resourceName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void apply(RuntimeConfiguration runtimeConfig) {
boolean currentEnabled = !Strings.isNullOrEmpty(currentConfig.connectionString);

updateConnectionString(runtimeConfig.connectionString);
if (initialConfig.preview.javaScriptSnippet.enabled) {
if (initialConfig.preview.browserSdkLoader.enabled) {
SnippetConfiguration.initializeSnippet(runtimeConfig.connectionString);
}
updateRoleName(runtimeConfig.role.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void customize(AutoConfigurationCustomizer autoConfiguration) {
}

if (telemetryClient.getConnectionString() != null) {
if (configuration.preview.javaScriptSnippet.enabled) {
if (configuration.preview.browserSdkLoader.enabled) {
SnippetConfiguration.initializeSnippet(configuration.connectionString);
}
}
Expand Down Expand Up @@ -392,8 +392,8 @@ private static Set<Feature> initStatsbeatFeatureSet(Configuration config) {
if (!config.preview.instrumentation.jaxrsAnnotations.enabled) {
featureList.add(Feature.JAXRS_ANNOTATIONS_DISABLED);
}
if (config.preview.javaScriptSnippet.enabled) {
featureList.add(Feature.JAVASCRIPT_SNIPPET);
if (config.preview.browserSdkLoader.enabled) {
featureList.add(Feature.BROWSER_SDK_LOADER);
}

// Statsbeat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public enum Feature {
TELEMETRY_PROCESSOR_ENABLED(33),
SDK_2X_BRIDGE_VIA_3X_AGENT(34), // track 2.x bridge usage via 3.x codeless agent
PROFILER_ENABLED(35),
JAVASCRIPT_SNIPPET(36); // track javascript snippet
BROWSER_SDK_LOADER(36); // track javascript snippet

private static final Map<String, Feature> javaVendorFeatureMap;

Expand Down
3 changes: 2 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ include(":smoke-tests:framework")
hideFromDependabot(":smoke-tests:apps:ActuatorMetrics")
hideFromDependabot(":smoke-tests:apps:AutoPerfCounters")
hideFromDependabot(":smoke-tests:apps:AzureSdk")
hideFromDependabot(":smoke-tests:apps:BrowserSdkLoader")
hideFromDependabot(":smoke-tests:apps:Cassandra")
hideFromDependabot(":smoke-tests:apps:ClassicSdkLog4j1Interop2x")
hideFromDependabot(":smoke-tests:apps:ClassicSdkLog4j2Interop2x")
Expand Down Expand Up @@ -132,7 +133,7 @@ hideFromDependabot(":smoke-tests:apps:RoleNameOverrides")
hideFromDependabot(":smoke-tests:apps:RuntimeAttach")
hideFromDependabot(":smoke-tests:apps:RuntimeAttachWithDelayedConnectionString")
hideFromDependabot(":smoke-tests:apps:Sampling")
hideFromDependabot(":smoke-tests:apps:SnippetInjection")

hideFromDependabot(":smoke-tests:apps:SamplingOverrides")
hideFromDependabot(":smoke-tests:apps:SamplingOverridesBackCompat")
hideFromDependabot(":smoke-tests:apps:SpringBoot")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,41 @@
import org.junit.jupiter.api.extension.RegisterExtension;

@UseAgent
abstract class SnippetInjectionTest {
abstract class BrowserSdkLoaderTest {
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create();

@Test
@TargetUri("/test")
void normalSnippetInjectionTest() throws Exception {
void normalBrowserSdkLoaderEnableTest() throws Exception {
String url = testing.getBaseUrl() + "/test";
String response = HttpHelper.get(url, "", emptyMap());
assertThat(response).contains("script");
assertThat(response).contains("InstrumentationKey=00000000");
}

@Environment(TOMCAT_8_JAVA_8)
static class Tomcat8Java8Test extends SnippetInjectionTest {}
static class Tomcat8Java8Test extends BrowserSdkLoaderTest {}

@Environment(TOMCAT_8_JAVA_8_OPENJ9)
static class Tomcat8Java8OpenJ9Test extends SnippetInjectionTest {}
static class Tomcat8Java8OpenJ9Test extends BrowserSdkLoaderTest {}

@Environment(TOMCAT_8_JAVA_11)
static class Tomcat8Java11Test extends SnippetInjectionTest {}
static class Tomcat8Java11Test extends BrowserSdkLoaderTest {}

@Environment(TOMCAT_8_JAVA_11_OPENJ9)
static class Tomcat8Java11OpenJ9Test extends SnippetInjectionTest {}
static class Tomcat8Java11OpenJ9Test extends BrowserSdkLoaderTest {}

@Environment(TOMCAT_8_JAVA_17)
static class Tomcat8Java17Test extends SnippetInjectionTest {}
static class Tomcat8Java17Test extends BrowserSdkLoaderTest {}

@Environment(TOMCAT_8_JAVA_19)
static class Tomcat8Java19Test extends SnippetInjectionTest {}
static class Tomcat8Java19Test extends BrowserSdkLoaderTest {}

@Environment(TOMCAT_8_JAVA_20)
static class Tomcat8Java20Test extends SnippetInjectionTest {}
static class Tomcat8Java20Test extends BrowserSdkLoaderTest {}

@Environment(WILDFLY_13_JAVA_8)
static class Wildfly13Java8Test extends SnippetInjectionTest {}
static class Wildfly13Java8Test extends BrowserSdkLoaderTest {}

@Environment(WILDFLY_13_JAVA_8_OPENJ9)
static class Wildfly13Java8OpenJ9Test extends SnippetInjectionTest {}
static class Wildfly13Java8OpenJ9Test extends BrowserSdkLoaderTest {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"preview": {
"browserSdkLoader":
{
"enabled": true
}
}
}

This file was deleted.