protected void withMethod(final Object bean, String beanName, Class<?> targetClass, final Method method) {
if (method.getParameterTypes().length > 0) {
throw new IllegalStateException("Method " + method.getName() + " is annotated with @Gauge but requires parameters.");
}
final Gauge annotation = method.getAnnotation(Gauge.class);
final String metricName = Util.forGauge(targetClass, method, annotation);
metrics.register(metricName, new com.codahale.metrics.Gauge<Object>() {
@Override
public Object getValue() {