/** * Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide * monitors. Emitted events have default feed {@link FeedDefiningMonitor#DEFAULT_METRICS_FEED} * See: {@link Monitors#createCompoundJvmMonitor(Map, String)} * * @param dimensions common dimensions to configure the JVM monitor with * * @return a universally useful JVM-wide monitor */ public static Monitor createCompoundJvmMonitor(Map<String, String[]> dimensions) { return createCompoundJvmMonitor(dimensions, FeedDefiningMonitor.DEFAULT_METRICS_FEED); }
/** * 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) ); }
/** * 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 public void testSetFeed() { String feed = "testFeed"; StubServiceEmitter emitter = new StubServiceEmitter("dev/monitor-test", "localhost:0000"); Monitor m = Monitors.createCompoundJvmMonitor(ImmutableMap.of(), feed); m.start(); m.monitor(emitter); m.stop(); checkEvents(emitter.getEvents(), feed); }
@Test public void testDefaultFeed() { StubServiceEmitter emitter = new StubServiceEmitter("dev/monitor-test", "localhost:0000"); Monitor m = Monitors.createCompoundJvmMonitor(ImmutableMap.of()); m.start(); m.monitor(emitter); m.stop(); checkEvents(emitter.getEvents(), "metrics"); }
/** * Creates a JVM monitor, configured with the given dimensions, that gathers all currently available JVM-wide * monitors. Emitted events have default feed {@link FeedDefiningMonitor#DEFAULT_METRICS_FEED} * See: {@link Monitors#createCompoundJvmMonitor(Map, String)} * * @param dimensions common dimensions to configure the JVM monitor with * * @return a universally useful JVM-wide monitor */ public static Monitor createCompoundJvmMonitor(Map<String, String[]> dimensions) { return createCompoundJvmMonitor(dimensions, FeedDefiningMonitor.DEFAULT_METRICS_FEED); }