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

[POC only] Use upstream detectors #4012

Draft
wants to merge 1 commit into
base: service-version
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -36,7 +36,9 @@ public Map<String, String> apply(ConfigProperties otelConfig) {
// enables all resource provider by default
properties.put(
"otel.java.enabled.resource.providers",
"io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider");
"io.opentelemetry.sdk.autoconfigure.internal.EnvironmentResourceProvider,"
+ "io.opentelemetry.instrumentation.resources.ManifestResourceProvider,"
+ "io.opentelemetry.instrumentation.spring.resources.SpringBootServiceVersionDetector");
Comment on lines +40 to +41
Copy link
Member Author

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


if (configuration.preview.captureControllerSpans) {
properties.put(
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ hideFromDependabot(":smoke-tests:apps:RuntimeAttachWithDelayedConnectionString")
hideFromDependabot(":smoke-tests:apps:Sampling")
hideFromDependabot(":smoke-tests:apps:SamplingOverrides")
hideFromDependabot(":smoke-tests:apps:SamplingOverridesBackCompat")
hideFromDependabot(":smoke-tests:apps:ServiceVersionFromManifest")
hideFromDependabot(":smoke-tests:apps:ServiceVersionFromSpring")
hideFromDependabot(":smoke-tests:apps:SpringBoot")
hideFromDependabot(":smoke-tests:apps:SpringBootAuto")
hideFromDependabot(":smoke-tests:apps:SpringBootAuto1_3")
Expand Down
15 changes: 15 additions & 0 deletions smoke-tests/apps/ServiceVersionFromManifest/build.gradle.kts
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"
)
}
}
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);
}
}
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";
}
}
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 {}
}
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>
7 changes: 7 additions & 0 deletions smoke-tests/apps/ServiceVersionFromSpring/build.gradle.kts
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")
}
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);
}
}
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";
}
}
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
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 {}
}
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>
Loading