public static void premain ( String arg , Instrumentation instrumentation ) throws Exception { // Setup logging Config config = loadConfig ( arg ) ; LOGGER . debug ( "loaded configuration: {}" , config . root ( ) . render ( ) ) ; createDependencyProperties ( config ) ; // Setup Registry AtlasRegistry registry = new AtlasRegistry ( Clock . SYSTEM , new AgentAtlasConfig ( config ) ) ; // Add to global registry for http stats and GC logger Spectator . globalRegistry ( ) . add ( registry ) ; // Enable GC logger GcLogger gcLogger = new GcLogger ( ) ; if ( config . getBoolean ( "collection.gc" ) ) { gcLogger . start ( null ) ; } // Enable JVM data collection if ( config . getBoolean ( "collection.jvm" ) ) { Jmx . registerStandardMXBeans ( registry ) ; } // Enable JMX query collection if ( config . getBoolean ( "collection.jmx" ) ) { for ( Config cfg : config . getConfigList ( "jmx.mappings" ) ) { Jmx . registerMappingsFromConfig ( registry , cfg ) ; } } // Start collection for the registry registry . start ( ) ; // Shutdown registry Runtime . getRuntime ( ) . addShutdownHook ( new Thread ( registry :: stop , "spectator-agent-shutdown" ) ) ; }
Entry point for the agent .