private void startJvmCollection() { try { Jmx.registerStandardMXBeans(sidecarRegistry); gcLogger = new GcLogger(); gcLogger.start(null); } catch (Exception e) { LOGGER.error("failed to start collection of jvm stats", e); throw e; } }
/** Create a new instance. */ @Inject Plugin(Registry registry, Config config) { final boolean enabled = config.getBoolean(ENABLED_PROP, true); if (enabled) { if (config.getBoolean("spectator.gc.loggingEnabled", true)) { GC_LOGGER.start(null); LOGGER.info("gc logging started"); } else { LOGGER.info("gc logging is not enabled"); } Jmx.registerStandardMXBeans(registry); } else { LOGGER.debug("plugin not enabled, set " + ENABLED_PROP + "=true to enable"); } } }
/** Create a new instance. */ @Inject Plugin(Registry registry, Config config) { final boolean enabled = config.getBoolean(ENABLED_PROP, true); if (enabled) { if (config.getBoolean("spectator.gc.loggingEnabled", true)) { GC_LOGGER.start(null); LOGGER.info("gc logging started"); } else { LOGGER.info("gc logging is not enabled"); } Jmx.registerStandardMXBeans(registry); } else { LOGGER.debug("plugin not enabled, set " + ENABLED_PROP + "=true to enable"); } } }
public RegistryInitializer(Registry registry, boolean enableJmxLogging) { this.registry = registry; Spectator.globalRegistry().add(registry); if (enableJmxLogging) { Jmx.registerStandardMXBeans(registry); } gcLogger = new GcLogger(); gcLogger.start(null); }
/** Entry point for the agent. */ 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")); }