Skip to content

Commit 9072de0

Browse files
committed
tidy a few things
1 parent d28fd42 commit 9072de0

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

jmx-scraper/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ testing {
2929
dependencies {
3030
implementation("org.testcontainers:junit-jupiter")
3131
implementation("org.slf4j:slf4j-simple")
32-
implementation("com.linecorp.armeria:armeria-grpc")
3332
implementation("com.linecorp.armeria:armeria-junit5")
3433
implementation("com.linecorp.armeria:armeria-grpc")
3534
implementation("io.opentelemetry.proto:opentelemetry-proto:0.20.0-alpha")

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxScraperContainer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
import static org.assertj.core.api.Assertions.assertThat;
99

10+
import com.google.errorprone.annotations.CanIgnoreReturnValue;
1011
import java.time.Duration;
1112
import java.util.ArrayList;
1213
import java.util.HashSet;
1314
import java.util.List;
1415
import java.util.Locale;
1516
import java.util.Set;
16-
import com.google.errorprone.annotations.CanIgnoreReturnValue;
1717
import org.testcontainers.containers.GenericContainer;
1818
import org.testcontainers.containers.wait.strategy.Wait;
1919
import org.testcontainers.utility.MountableFile;
@@ -108,6 +108,8 @@ public void start() {
108108

109109
this.withCommand(arguments.toArray(new String[0]));
110110

111+
logger().info("Starting scraper with command: " + String.join(" ", arguments));
112+
111113
super.start();
112114
}
113115
}

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/TestAppContainer.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import java.util.HashMap;
1717
import java.util.Map;
1818
import java.util.stream.Collectors;
19-
import org.slf4j.Logger;
20-
import org.slf4j.LoggerFactory;
2119
import org.testcontainers.containers.GenericContainer;
2220
import org.testcontainers.containers.wait.strategy.Wait;
2321
import org.testcontainers.shaded.com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -26,8 +24,6 @@
2624
/** Test container that allows to execute {@link TestApp} in an isolated container */
2725
public class TestAppContainer extends GenericContainer<TestAppContainer> {
2826

29-
private static final Logger logger = LoggerFactory.getLogger(TestAppContainer.class);
30-
3127
private final Map<String, String> properties;
3228
private int port;
3329
private String login;
@@ -101,11 +97,11 @@ public void start() {
10197

10298
this.withEnv("JAVA_TOOL_OPTIONS", confArgs);
10399

104-
logger.info("Test application JAVA_TOOL_OPTIONS = " + confArgs);
100+
logger().info("Test application JAVA_TOOL_OPTIONS = " + confArgs);
105101

106102
super.start();
107103

108-
logger.info("Test application JMX port mapped to {}:{}", getHost(), getMappedPort(port));
104+
logger().info("Test application JMX port mapped to {}:{}", getHost(), getMappedPort(port));
109105
}
110106

111107
private static Path createPwdFile(String login, String pwd) {

jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/target_systems/TargetSystemIntegrationTest.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
public abstract class TargetSystemIntegrationTest {
3838

3939
private static final Logger logger = LoggerFactory.getLogger(TargetSystemIntegrationTest.class);
40+
public static final String TARGET_SYSTEM_NETWORK_ALIAS = "targetsystem";
4041
private static String otlpEndpoint;
4142

4243
/**
@@ -95,28 +96,30 @@ void endToEndTest() {
9596
.withLogConsumer(new Slf4jLogConsumer(logger))
9697
.withNetwork(network)
9798
.withExposedPorts(JMX_PORT)
98-
.withNetworkAliases("target_system");
99+
.withNetworkAliases(TARGET_SYSTEM_NETWORK_ALIAS);
99100
target.start();
100101

101102
String targetHost = target.getHost();
102103
Integer targetPort = target.getMappedPort(JMX_PORT);
103104
logger.info(
104105
"Target system started, JMX port: {} mapped to {}:{}", JMX_PORT, targetHost, targetPort);
105106

106-
scraper = new JmxScraperContainer(otlpEndpoint).withService("target_system", JMX_PORT);
107-
108-
scraper = customizeScraperContainer(scraper);
109-
logger.info("starting scraper with command: {}", String.join(" ", scraper.getCommandParts()));
110-
111-
scraper.start();
112-
113107
// TODO : wait for metrics to be sent and add assertions on what is being captured
114108
// for now we just test that we can connect to remote JMX using our client.
115109
try (JMXConnector connector = JmxRemoteClient.createNew(targetHost, targetPort).connect()) {
116110
assertThat(connector.getMBeanServerConnection()).isNotNull();
117111
} catch (IOException e) {
118112
throw new RuntimeException(e);
119113
}
114+
115+
scraper =
116+
new JmxScraperContainer(otlpEndpoint)
117+
.withNetwork(network)
118+
.withService(TARGET_SYSTEM_NETWORK_ALIAS, JMX_PORT);
119+
120+
scraper = customizeScraperContainer(scraper);
121+
scraper.start();
122+
120123
// TODO: replace with real assertions
121124
assertThat(otlpServer.getMetrics()).isEmpty();
122125
}

jmx-scraper/src/main/java/io/opentelemetry/contrib/jmxscraper/JmxScraper.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,12 @@ private void start() {
126126
// service.startRemote(metricConfig, () -> Collections.singletonList(connection));
127127

128128
logger.info("JMX scraping started");
129+
130+
// TODO: wait a bit to keep the JVM running, this won't be needed once calling jmx insight
131+
try {
132+
Thread.sleep(5000);
133+
} catch (InterruptedException e) {
134+
throw new IllegalStateException(e);
135+
}
129136
}
130137
}

0 commit comments

Comments
 (0)