@Override public RegistryConfig config() { return composite.config(); }
/** Create a new instance. */ Builder(Registry registry, Id baseId) { super(); this.registry = registry; this.baseId = baseId; this.delay = registry.config().gaugePollingFrequency().toMillis(); }
/** Create a new instance. */ Builder(Registry registry, Id baseId) { super(); this.registry = registry; this.baseId = baseId; this.delay = registry.config().gaugePollingFrequency().toMillis(); }
/** * Log a warning and if enabled propagate the exception {@code t}. As a general rule * instrumentation code should degrade gracefully and avoid impacting the core application. If * the user makes a mistake and causes something to break, then it should not impact the * application unless that mistake triggers a problem outside of the instrumentation code. * However, in test code it is often better to throw so that mistakes are caught and corrected. * * This method is used to handle exceptions internal to the instrumentation code. Propagation * is controlled by the {@link RegistryConfig#propagateWarnings()} setting. If the setting * is true, then the exception will be propagated. Otherwise the exception will only get logged * as a warning. * * @param msg * Message written out to the log. * @param t * Exception to log and optionally propagate. */ default void propagate(String msg, Throwable t) { LoggerFactory.getLogger(getClass()).warn(msg, t); if (config().propagateWarnings()) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } } /**
/** * Log a warning and if enabled propagate the exception {@code t}. As a general rule * instrumentation code should degrade gracefully and avoid impacting the core application. If * the user makes a mistake and causes something to break, then it should not impact the * application unless that mistake triggers a problem outside of the instrumentation code. * However, in test code it is often better to throw so that mistakes are caught and corrected. * * This method is used to handle exceptions internal to the instrumentation code. Propagation * is controlled by the {@link RegistryConfig#propagateWarnings()} setting. If the setting * is true, then the exception will be propagated. Otherwise the exception will only get logged * as a warning. * * @param msg * Message written out to the log. * @param t * Exception to log and optionally propagate. */ default void propagate(String msg, Throwable t) { LoggerFactory.getLogger(getClass()).warn(msg, t); if (config().propagateWarnings()) { if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } } /**
/** * Provided for backwards compatibility to support the {@link Registry#register(Meter)} * method. Use the builder created with {@link #using(Registry)} instead. * * @deprecated This method only exists to allow for backwards compatibility and should * be considered an internal detail. Scheduled to be removed in 2.0. */ @Deprecated public static void monitorMeter(Registry registry, Meter meter) { ConcurrentMap<Id, Object> state = registry.state(); Object c = Utils.computeIfAbsent(state, meter.id(), MeterState::new); if (!(c instanceof MeterState)) { Utils.propagateTypeError(registry, meter.id(), MeterState.class, c.getClass()); } else { MeterState t = (MeterState) c; t.add(meter); long delay = registry.config().gaugePollingFrequency().toMillis(); t.schedule(registry, null, delay); } }
/** * Provided for backwards compatibility to support the {@link Registry#register(Meter)} * method. Use the builder created with {@link #using(Registry)} instead. * * @deprecated This method only exists to allow for backwards compatibility and should * be considered an internal detail. Scheduled to be removed in 2.0. */ @Deprecated public static void monitorMeter(Registry registry, Meter meter) { ConcurrentMap<Id, Object> state = registry.state(); Object c = Utils.computeIfAbsent(state, meter.id(), MeterState::new); if (!(c instanceof MeterState)) { Utils.propagateTypeError(registry, meter.id(), MeterState.class, c.getClass()); } else { MeterState t = (MeterState) c; t.add(meter); long delay = registry.config().gaugePollingFrequency().toMillis(); t.schedule(registry, null, delay); } }