@Override public void stop() { LOGGER.info("stopping poller"); reporter.stop(); gcLogger.stop(); if (sidecarRegistry != null) { sidecarRegistry.stop(); } }
/** 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"); } } }
private void processGcEvent(GarbageCollectionNotificationInfo info) { GcEvent event = new GcEvent(info, jvmStartTime + info.getGcInfo().getStartTime()); gcLogs.get(info.getGcName()).add(event); if (LOGGER.isDebugEnabled()) { LOGGER.debug(event.toString()); } // Update pause timer for the action and cause... Id eventId = (isConcurrentPhase(info) ? CONCURRENT_PHASE_TIME : PAUSE_TIME) .withTag("action", info.getGcAction()) .withTag("cause", info.getGcCause()); Timer timer = Spectator.globalRegistry().timer(eventId); timer.record(info.getGcInfo().getDuration(), TimeUnit.MILLISECONDS); // Update promotion and allocation counters updateMetrics(info.getGcName(), info.getGcInfo()); // Notify an event listener if registered if (eventListener != null) { try { eventListener.onComplete(event); } catch (Exception e) { LOGGER.warn("exception thrown by event listener", 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"); } } }
private void processGcEvent(GarbageCollectionNotificationInfo info) { GcEvent event = new GcEvent(info, jvmStartTime + info.getGcInfo().getStartTime()); gcLogs.get(info.getGcName()).add(event); if (LOGGER.isDebugEnabled()) { LOGGER.debug(event.toString()); } // Update pause timer for the action and cause... Id eventId = (isConcurrentPhase(info) ? CONCURRENT_PHASE_TIME : PAUSE_TIME) .withTag("action", info.getGcAction()) .withTag("cause", info.getGcCause()); Timer timer = Spectator.globalRegistry().timer(eventId); timer.record(info.getGcInfo().getDuration(), TimeUnit.MILLISECONDS); // Update promotion and allocation counters updateMetrics(info.getGcName(), info.getGcInfo()); // Notify an event listener if registered if (eventListener != null) { try { eventListener.onComplete(event); } catch (Exception e) { LOGGER.warn("exception thrown by event listener", e); } } }
@PreDestroy public void destroy() { gcLogger.stop(); Spectator.globalRegistry().remove(registry); } }
/** 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")); }