-
Notifications
You must be signed in to change notification settings - Fork 201
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
[POC only] Use upstream detectors #4012
Draft
trask
wants to merge
1
commit into
service-version
Choose a base branch
from
service-version-autodetect
base: service-version
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 15 additions & 0 deletions
15
smoke-tests/apps/ServiceVersionFromManifest/build.gradle.kts
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,15 @@ | ||
plugins { | ||
id("ai.smoke-test-jar") | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-web:2.5.12") | ||
} | ||
|
||
tasks.withType<Jar> { | ||
manifest { | ||
attributes( | ||
"Implementation-Version" to "1.2.3" | ||
) | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...mManifest/src/main/java/com/microsoft/applicationinsights/smoketestapp/SpringBootApp.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,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringBootApp { | ||
|
||
public static void main(String[] args) { | ||
|
||
SpringApplication.run(SpringBootApp.class, args); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...Manifest/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.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,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class TestController { | ||
|
||
@GetMapping("/") | ||
public String root() { | ||
return "OK"; | ||
} | ||
|
||
@GetMapping("/test") | ||
public String test() { | ||
return "hello"; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...st/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/ApplicationVerTest.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,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.JAVA_11; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_11_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_17; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_17_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_21; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_21_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_8_OPENJ9; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.data.MapEntry.entry; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent | ||
abstract class ApplicationVerTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri("/test") | ||
void test() throws Exception { | ||
Telemetry telemetry = testing.getTelemetry(0); | ||
|
||
assertThat(telemetry.rd.getName()).isEqualTo("GET /test"); | ||
assertThat(telemetry.rd.getUrl()).matches("http://localhost:[0-9]+/test"); | ||
assertThat(telemetry.rd.getResponseCode()).isEqualTo("200"); | ||
assertThat(telemetry.rd.getSuccess()).isTrue(); | ||
assertThat(telemetry.rd.getSource()).isNull(); | ||
assertThat(telemetry.rd.getProperties()) | ||
.containsExactly(entry("_MS.ProcessedByMetricExtractors", "True")); | ||
assertThat(telemetry.rd.getMeasurements()).isEmpty(); | ||
|
||
assertThat(telemetry.rdEnvelope.getTags()).containsEntry("ai.application.ver", "1.2.3"); | ||
} | ||
|
||
@Environment(JAVA_8) | ||
static class Java8Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_8_OPENJ9) | ||
static class Java8OpenJ9Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_11) | ||
static class Java11Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_11_OPENJ9) | ||
static class Java11OpenJ9Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_17) | ||
static class Java17Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_17_OPENJ9) | ||
static class Java17OpenJ9Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_21) | ||
static class Java21Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_21_OPENJ9) | ||
static class Java21OpenJ9Test extends ApplicationVerTest {} | ||
} |
11 changes: 11 additions & 0 deletions
11
smoke-tests/apps/ServiceVersionFromManifest/src/smokeTest/resources/logback-test.xml
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="warn"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
</configuration> |
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,7 @@ | ||
plugins { | ||
id("ai.smoke-test-jar") | ||
} | ||
|
||
dependencies { | ||
implementation("org.springframework.boot:spring-boot-starter-web:2.5.12") | ||
} |
16 changes: 16 additions & 0 deletions
16
...romSpring/src/main/java/com/microsoft/applicationinsights/smoketestapp/SpringBootApp.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,16 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringBootApp { | ||
|
||
public static void main(String[] args) { | ||
|
||
SpringApplication.run(SpringBootApp.class, args); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...omSpring/src/main/java/com/microsoft/applicationinsights/smoketestapp/TestController.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,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class TestController { | ||
|
||
@GetMapping("/") | ||
public String root() { | ||
return "OK"; | ||
} | ||
|
||
@GetMapping("/test") | ||
public String test() { | ||
return "hello"; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
smoke-tests/apps/ServiceVersionFromSpring/src/main/resources/META-INF/build-info.properties
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,3 @@ | ||
build.artifact=something | ||
build.name=some-name | ||
build.version=2.3.4 |
65 changes: 65 additions & 0 deletions
65
...ng/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/ApplicationVerTest.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,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.JAVA_11; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_11_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_17; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_17_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_21; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_21_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.JAVA_8_OPENJ9; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.data.MapEntry.entry; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent | ||
abstract class ApplicationVerTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri("/test") | ||
void test() throws Exception { | ||
Telemetry telemetry = testing.getTelemetry(0); | ||
|
||
assertThat(telemetry.rd.getName()).isEqualTo("GET /test"); | ||
assertThat(telemetry.rd.getUrl()).matches("http://localhost:[0-9]+/test"); | ||
assertThat(telemetry.rd.getResponseCode()).isEqualTo("200"); | ||
assertThat(telemetry.rd.getSuccess()).isTrue(); | ||
assertThat(telemetry.rd.getSource()).isNull(); | ||
assertThat(telemetry.rd.getProperties()) | ||
.containsExactly(entry("_MS.ProcessedByMetricExtractors", "True")); | ||
assertThat(telemetry.rd.getMeasurements()).isEmpty(); | ||
|
||
assertThat(telemetry.rdEnvelope.getTags()).containsEntry("ai.application.ver", "2.3.4"); | ||
} | ||
|
||
@Environment(JAVA_8) | ||
static class Java8Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_8_OPENJ9) | ||
static class Java8OpenJ9Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_11) | ||
static class Java11Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_11_OPENJ9) | ||
static class Java11OpenJ9Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_17) | ||
static class Java17Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_17_OPENJ9) | ||
static class Java17OpenJ9Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_21) | ||
static class Java21Test extends ApplicationVerTest {} | ||
|
||
@Environment(JAVA_21_OPENJ9) | ||
static class Java21OpenJ9Test extends ApplicationVerTest {} | ||
} |
11 changes: 11 additions & 0 deletions
11
smoke-tests/apps/ServiceVersionFromSpring/src/smokeTest/resources/logback-test.xml
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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="warn"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
</configuration> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not sure if we should add these two upstream detectors without a major version bump since these will start populating role name and app version in cases where they were previously empty