@Override public void register(Meter meter) { impl.register(meter); }
@Override public void register(Meter meter) { impl.register(meter); }
@Override public void register(Meter meter) { composite.register(meter); }
/** * Add meters based on configured JMX queries. See the {@link JmxConfig} class for more * details. * * @param registry * Registry to use for reporting the data. * @param cfg * Config object with the mappings. */ public static void registerMappingsFromConfig(Registry registry, Config cfg) { registry.register(new JmxMeter(registry, JmxConfig.from(cfg))); } }
/** * Add meters for the standard MXBeans provided by the jvm. This method will use * {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)} to get the set of * mbeans from the local jvm. */ public static void registerStandardMXBeans(Registry registry) { for (MemoryPoolMXBean mbean : ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class)) { registry.register(new MemoryPoolMeter(registry, mbean)); } for (BufferPoolMXBean mbean : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) { registry.register(new BufferPoolMeter(registry, mbean)); } }
/** * Add meters for the standard MXBeans provided by the jvm. This method will use * {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)} to get the set of * mbeans from the local jvm. */ public static void registerStandardMXBeans(Registry registry) { for (MemoryPoolMXBean mbean : ManagementFactory.getPlatformMXBeans(MemoryPoolMXBean.class)) { registry.register(new MemoryPoolMeter(registry, mbean)); } for (BufferPoolMXBean mbean : ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class)) { registry.register(new BufferPoolMeter(registry, mbean)); } }
/** * Get or create a double distribution summary with the specified id. * * @param registry * Registry to use. * @param id * Identifier for the metric being registered. * @return * Distribution summary corresponding to the id. */ static DoubleDistributionSummary get(Registry registry, Id id) { DoubleDistributionSummary instance = INSTANCES.get(id); if (instance == null) { final Clock c = registry.clock(); DoubleDistributionSummary tmp = new DoubleDistributionSummary(c, id, RESET_FREQ); instance = INSTANCES.putIfAbsent(id, tmp); if (instance == null) { instance = tmp; registry.register(tmp); } } return instance; }
/** * Add meters based on configured JMX queries. See the {@link JmxConfig} class for more * details. * * @param registry * Registry to use for reporting the data. * @param cfg * Config object with the mappings. */ public static void registerMappingsFromConfig(Registry registry, Config cfg) { registry.register(new JmxMeter(registry, JmxConfig.from(cfg))); } }
/** * Get or create a double distribution summary with the specified id. * * @param registry * Registry to use. * @param id * Identifier for the metric being registered. * @return * Distribution summary corresponding to the id. */ static DoubleDistributionSummary get(Registry registry, Id id) { DoubleDistributionSummary instance = INSTANCES.get(id); if (instance == null) { final Clock c = registry.clock(); DoubleDistributionSummary tmp = new DoubleDistributionSummary(c, id, RESET_FREQ); instance = INSTANCES.putIfAbsent(id, tmp); if (instance == null) { instance = tmp; registry.register(tmp); } } return instance; }
@Test public void testRegister() { Registry r = newRegistry(5, true); Counter c = new DefaultCounter(clock, r.createId("foo")); r.register(c); c.increment(); Assertions.assertEquals(c.count(), 1L); r.register(c); PolledMeter.update(r); Meter meter = r.get(c.id()); for (Measurement m : meter.measure()) { Assertions.assertEquals(m.value(), 2.0, 1e-12); } }
@Test public void testRegisterBadTypeAccessNoThrow() { Registry r = newRegistry(5, false); Counter c = new DefaultCounter(clock, r.createId("foo")); r.counter(c.id()); r.register(c); Assertions.assertNotSame(r.get(c.id()), c); }
@Disabled public void testRegister() { DoubleDistributionSummary t = newInstance(); registry.register(t); t.record(42.0); clock.setWallTime(65000L); for (Measurement m : registry.get(t.id()).measure()) { Assertions.assertEquals(m.timestamp(), 65000L); switch (get(m.id(), "statistic")) { case "count": Assertions.assertEquals(m.value(), 1.0 / 65.0, 1e-12); break; case "totalAmount": Assertions.assertEquals(m.value(), 42.0 / 65.0, 1e-12); break; case "totalOfSquares": Assertions.assertEquals(m.value(), 42.0 * 42.0 / 65.0, 1e-12); break; case "max": Assertions.assertEquals(m.value(), 42.0, 1e-12); break; default: Assertions.fail("unexpected id: " + m.id()); break; } } }