@Override public void methodValue(String name, Object obj, String method) { composite.methodValue(name, obj, method); }
@Override public void methodValue(Id id, Object obj, String method) { composite.methodValue(id, obj, method); }
/** * Tells the registry to regularly poll the object by by using reflection to invoke the named * method and report the returned value as a gauge. See {@link #methodValue(Id, Object, String)} * for more information. * * @param name * Name of the metric being registered. * @param obj * Object used to compute a value. * @param method * Name of the method to invoke on the object. * @deprecated * Use {@link PolledMeter} instead. This method has been deprecated to help * reduce confusion between active gauges that are explicitly updated by the * user and passive gauges that are polled in the background. Going forward * the registry methods will only be used for the core types directly updated * by the user. Other patterns such as {@link PolledMeter}s will be handled * separately. Scheduled to be removed in 2.0. */ @Deprecated default void methodValue(String name, Object obj, String method) { methodValue(createId(name), obj, method); }
/** * Tells the registry to regularly poll the object by by using reflection to invoke the named * method and report the returned value as a gauge. See {@link #methodValue(Id, Object, String)} * for more information. * * @param name * Name of the metric being registered. * @param obj * Object used to compute a value. * @param method * Name of the method to invoke on the object. * @deprecated * Use {@link PolledMeter} instead. This method has been deprecated to help * reduce confusion between active gauges that are explicitly updated by the * user and passive gauges that are polled in the background. Going forward * the registry methods will only be used for the core types directly updated * by the user. Other patterns such as {@link PolledMeter}s will be handled * separately. Scheduled to be removed in 2.0. */ @Deprecated default void methodValue(String name, Object obj, String method) { methodValue(createId(name), obj, method); }
@Test public void methodValueUnknown() { Assertions.assertThrows(RuntimeException.class, () -> { Registry r = newRegistry(true, 10000); r.methodValue("queueSize", this, "unknownMethod"); }); }
@Test public void methodValueBadReturnType() { Assertions.assertThrows(ClassCastException.class, () -> { Registry r = newRegistry(true, 10000); r.methodValue("queueSize", this, "toString"); }); }
@Test public void testMethodValueHelpers() { Registry r = newRegistry(true, 10000); LinkedBlockingDeque<String> q1 = new LinkedBlockingDeque<>(); r.methodValue("queueSize", q1, "size"); Id id = r.createId("queueSize"); assertGaugeValue(r, id, 0.0); q1.push("foo"); assertGaugeValue(r, id, 1.0); }
@Test public void methodValueBadReturnTypeNoPropagate() { Registry r = newRegistry(false, 10000); r.methodValue("queueSize", this, "toString"); Assertions.assertNull(r.get(r.createId("queueSize"))); }
@Test public void methodValueUnknownNoPropagate() { Registry r = newRegistry(false, 10000); r.methodValue("queueSize", this, "unknownMethod"); Assertions.assertNull(r.get(r.createId("queueSize"))); }