@Provides @ManageLifecycle public JvmMonitor getJvmMonitor( DataSourceTaskIdHolder dataSourceTaskIdHolder ) { Map<String, String[]> dimensions = MonitorsConfig.mapOfDatasourceAndTaskID( dataSourceTaskIdHolder.getDataSource(), dataSourceTaskIdHolder.getTaskId() ); return new JvmMonitor(dimensions); }
/** * Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide * monitors: {@link JvmMonitor}, {@link JvmCpuMonitor} and {@link JvmThreadsMonitor} (this list may * change in any future release of this library, including a minor release). * * @param dimensions common dimensions to configure the JVM monitor with * @param feed feed for all emitted events * * @return a universally useful JVM-wide monitor */ public static Monitor createCompoundJvmMonitor(Map<String, String[]> dimensions, String feed) { // This list doesn't include SysMonitor because it should probably be run only in one JVM, if several JVMs are // running on the same instance, so most of the time SysMonitor should be configured/set up differently than // "simple" JVM monitors, created below. return and(// Could equally be or(), because all member monitors always return true from their monitor() methods. new JvmMonitor(dimensions, feed), new JvmCpuMonitor(dimensions, feed), new JvmThreadsMonitor(dimensions, feed) ); }
@Test(timeout = 60_000L) public void testGcCounts() throws InterruptedException { GcTrackingEmitter emitter = new GcTrackingEmitter(); final ServiceEmitter serviceEmitter = new ServiceEmitter("test", "localhost", emitter); serviceEmitter.start(); final JvmMonitor jvmMonitor = new JvmMonitor(); while (true) { // generate some garbage to see gc counters incremented @SuppressWarnings("unused") byte[] b = new byte[1024 * 1024 * 50]; emitter.reset(); jvmMonitor.doMonitor(serviceEmitter); if (emitter.gcSeen()) { return; } Thread.sleep(10); } }
@Provides @ManageLifecycle public JvmMonitor getJvmMonitor( DataSourceTaskIdHolder dataSourceTaskIdHolder ) { Map<String, String[]> dimensions = MonitorsConfig.mapOfDatasourceAndTaskID( dataSourceTaskIdHolder.getDataSource(), dataSourceTaskIdHolder.getTaskId() ); return new JvmMonitor(dimensions); }
/** * Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide * monitors: {@link JvmMonitor}, {@link JvmCpuMonitor} and {@link JvmThreadsMonitor} (this list may * change in any future release of this library, including a minor release). * * @param dimensions common dimensions to configure the JVM monitor with * @param feed feed for all emitted events * * @return a universally useful JVM-wide monitor */ public static Monitor createCompoundJvmMonitor(Map<String, String[]> dimensions, String feed) { // This list doesn't include SysMonitor because it should probably be run only in one JVM, if several JVMs are // running on the same instance, so most of the time SysMonitor should be configured/set up differently than // "simple" JVM monitors, created below. return and(// Could equally be or(), because all member monitors always return true from their monitor() methods. new JvmMonitor(dimensions, feed), new JvmCpuMonitor(dimensions, feed), new JvmThreadsMonitor(dimensions, feed) ); }