@@ -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}
0 commit comments