Skip to content

Commit 3b5a30b

Browse files
committed
use builder
1 parent 684aaf3 commit 3b5a30b

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

smoke-tests/src/main/java/io/opentelemetry/smoketest/SmokeTestInstrumentationExtension.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public SmokeTestOutput start(String jdk, String serverVersion, boolean windows)
138138
autoCleanup.deferCleanup(() -> containerManager.stopTarget());
139139

140140
return new SmokeTestOutput(
141+
this,
141142
containerManager.startTarget(
142143
getTargetImage.getTargetImage(jdk, serverVersion, windows),
143144
agentPath,

smoke-tests/src/main/java/io/opentelemetry/smoketest/SmokeTestOutput.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ public class SmokeTestOutput {
1919

2020
private static final Pattern TRACE_ID_PATTERN =
2121
Pattern.compile(".*trace_id=(?<traceId>[a-zA-Z0-9]+).*");
22+
private final SmokeTestInstrumentationExtension extension;
2223
private final Consumer<OutputFrame> output;
2324

24-
public SmokeTestOutput(Consumer<OutputFrame> output) {
25+
public SmokeTestOutput(
26+
SmokeTestInstrumentationExtension extension, Consumer<OutputFrame> output) {
27+
this.extension = extension;
2528
this.output = output;
2629
}
2730

@@ -30,7 +33,8 @@ public static Stream<String> findTraceId(String log) {
3033
return m.matches() ? Stream.of(m.group("traceId")) : Stream.empty();
3134
}
3235

33-
public void assertVersionLogged(String version) {
36+
public void assertAgentVersionLogged() {
37+
String version = extension.getAgentImplementationVersion();
3438
assertThat(
3539
logLines().anyMatch(l -> l.contains("opentelemetry-javaagent - version: " + version)))
3640
.isTrue();

smoke-tests/src/test/java/io/opentelemetry/smoketest/SdkDisabledSmokeTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
99

1010
import java.time.Duration;
11-
import java.util.jar.Attributes;
12-
import java.util.jar.JarFile;
1311
import org.junit.jupiter.api.condition.DisabledIf;
1412
import org.junit.jupiter.api.extension.RegisterExtension;
1513
import org.junit.jupiter.params.ParameterizedTest;
@@ -31,7 +29,7 @@ void noopSdkSmokeTest(int jdk) throws Exception {
3129
SmokeTestOutput output = testing.start(jdk);
3230
assertThat(testing.client().get("/greeting").aggregate().join().contentUtf8()).isEqualTo("Hi!");
3331
assertThat(testing.spans()).isEmpty();
34-
output.assertVersionLogged(testing.getAgentImplementationVersion());
32+
output.assertAgentVersionLogged();
3533
assertThat(testing.spans()).isEmpty();
3634
}
3735
}

smoke-tests/src/test/java/io/opentelemetry/smoketest/SpringBootSmokeTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ class SpringBootSmokeTest {
3535

3636
@ParameterizedTest
3737
@ValueSource(ints = {8, 11, 17, 21, 23})
38-
void springBootSmokeTest(int jdk) throws Exception {
38+
void springBootSmokeTest(int jdk) {
3939
SmokeTestOutput output = testing.start(jdk);
40-
String currentAgentVersion = testing.getAgentImplementationVersion();
4140

4241
var response = testing.client().get("/greeting").aggregate().join();
4342
assertThat(response.contentUtf8()).isEqualTo("Hi!");
@@ -56,7 +55,7 @@ void springBootSmokeTest(int jdk) throws Exception {
5655
resource
5756
.hasAttribute(
5857
TelemetryIncubatingAttributes.TELEMETRY_DISTRO_VERSION,
59-
currentAgentVersion)
58+
testing.getAgentImplementationVersion())
6059
.hasAttribute(
6160
satisfies(
6261
OsIncubatingAttributes.OS_TYPE, a -> a.isNotNull()))
@@ -69,7 +68,7 @@ void springBootSmokeTest(int jdk) throws Exception {
6968
span -> span.hasName("WebController.withSpan")));
7069

7170
// Check agent version is logged on startup
72-
output.assertVersionLogged(currentAgentVersion);
71+
output.assertAgentVersionLogged();
7372

7473
// Check trace IDs are logged via MDC instrumentation
7574
Set<String> loggedTraceIds = output.getLoggedTraceIds();

0 commit comments

Comments
 (0)