Skip to content

Commit 93bf770

Browse files
committed
add comments for future config enhancement
1 parent 7f7681b commit 93bf770

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

jmx-scraper/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ repositories {
2020
maven {
2121
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
2222
}
23-
2423
}
2524

26-
2725
dependencies {
2826
// TODO remove snapshot dependency on upstream once 2.9.0 is released
2927
api(enforcedPlatform("io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.9.0-alpha-SNAPSHOT"))

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class JmxScraper {
4646
public static void main(String[] args) {
4747

4848
// enable SDK auto-configure if not explicitly set by user
49+
// TODO: refactor this to use AutoConfiguredOpenTelemetrySdk
4950
if (System.getProperty(OTEL_AUTOCONFIGURE) == null) {
5051
System.setProperty(OTEL_AUTOCONFIGURE, "true");
5152
}
@@ -57,10 +58,11 @@ public static void main(String[] args) {
5758
// this also enables SDK auto-configuration to use those properties
5859
config.propagateSystemProperties();
5960

60-
JmxMetricInsight service = JmxMetricInsight.createService(GlobalOpenTelemetry.get(),
61-
config.getIntervalMilliseconds());
62-
JmxScraper jmxScraper = new JmxScraper(JmxConnectorBuilder.createNew(config.getServiceUrl()),
63-
service, config);
61+
JmxMetricInsight service =
62+
JmxMetricInsight.createService(
63+
GlobalOpenTelemetry.get(), config.getIntervalMilliseconds());
64+
JmxScraper jmxScraper =
65+
new JmxScraper(JmxConnectorBuilder.createNew(config.getServiceUrl()), service, config);
6466
jmxScraper.start();
6567

6668
} catch (ArgumentsParsingException e) {
@@ -133,10 +135,13 @@ private static Properties loadPropertiesFromPath(String path) throws Configurati
133135
}
134136

135137
private void start() throws IOException {
136-
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
137-
logger.info("JMX scraping stopped");
138-
running.set(false);
139-
}));
138+
Runtime.getRuntime()
139+
.addShutdownHook(
140+
new Thread(
141+
() -> {
142+
logger.info("JMX scraping stopped");
143+
running.set(false);
144+
}));
140145

141146
try (JMXConnector connector = client.build()) {
142147
MBeanServerConnection connection = connector.getMBeanServerConnection();
@@ -183,6 +188,4 @@ private static void addRulesForSystem(String system, MetricConfiguration conf) {
183188
throw new IllegalStateException("error while loading rules for system " + system, e);
184189
}
185190
}
186-
187-
188191
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public class JmxScraperConfig {
5555
private String serviceUrl = "";
5656
private String customJmxScrapingConfigPath = "";
5757
private Set<String> targetSystems = Collections.emptySet();
58-
private int intervalMilliseconds;
59-
private String metricsExporterType = "";
60-
private String otlpExporterEndpoint = "";
58+
private int intervalMilliseconds; // TODO only used to set 'otel.metric.export.interval' from SDK
59+
private String metricsExporterType = ""; // TODO only used to default to 'logging' if not set
60+
private String otlpExporterEndpoint = ""; // TODO not really needed here as handled by SDK
6161
private String username = "";
6262
private String password = "";
6363
private String realm = "";

0 commit comments

Comments
 (0)