/** * Returns a stopwatch that has been started and will automatically record its result to the * dynamic timer specified by the given name, and sequence of (key, value) pairs. The timer uses a * TimeUnit of milliseconds. */ public static Stopwatch start(String name, String... tags) { final MonitorConfig.Builder configBuilder = MonitorConfig.builder(name); Preconditions.checkArgument( tags.length % 2 == 0, "The sequence of (key, value) pairs must have even size: one key, one value"); for (int i = 0; i < tags.length; i += 2) { configBuilder.withTag(tags[i], tags[i + 1]); } return INSTANCE.get(configBuilder.build(), TimeUnit.MILLISECONDS).start(); }
/** * Returns a stopwatch that has been started and will automatically record its result to the * dynamic timer specified by the given config. The timer uses a TimeUnit of milliseconds. */ public static Stopwatch start(String name, TagList list, TimeUnit unit) { final MonitorConfig config = new MonitorConfig.Builder(name).withTags(list).build(); return INSTANCE.get(config, unit).start(); }
/** * Record a duration to the dynamic timer indicated by the provided config/reportUnit. * * @param config Config to identify a particular timer instance to update. * @param reportUnit The unit to use when reporting values to observers. For example if sent to a * typical time series graphing system this would be the unit for the y-axis. It is generally * recommended to use base units for reporting, so {@link TimeUnit#SECONDS} is the preferred * value. * @param duration Measured duration to record. * @param durationUnit Unit for the measured duration. This should typically be the unit used for * timing source. For example if using {@link System#nanoTime()} the unit would be * nanoseconds. */ public static void record( MonitorConfig config, TimeUnit reportUnit, long duration, TimeUnit durationUnit) { INSTANCE.get(config, reportUnit).record(duration, durationUnit); }
/** * Record a duration to the dynamic timer indicated by the provided config. The units in which the * timer is reported and the duration unit are the same. * * @deprecated Use {@link DynamicTimer#record(MonitorConfig, java.util.concurrent.TimeUnit, long, * java.util.concurrent.TimeUnit)} instead. The new method allows you to be specific about the * units used for reporting the timer and the units in which the duration is measured. */ public static void record(MonitorConfig config, long duration, TimeUnit unit) { INSTANCE.get(config, unit).record(duration, unit); }
/** * Record result to the dynamic timer indicated by the provided config with a TimeUnit of * milliseconds. */ public static void record(MonitorConfig config, long duration) { INSTANCE.get(config, TimeUnit.MILLISECONDS).record(duration, TimeUnit.MILLISECONDS); }
/** * Returns a stopwatch that has been started and will automatically record its result to the * dynamic timer specified by the given config. The timer will report the times in milliseconds to * observers. * * @see #start(MonitorConfig, TimeUnit) */ public static Stopwatch start(MonitorConfig config) { return INSTANCE.get(config, TimeUnit.MILLISECONDS).start(); }
/** * Returns a stopwatch that has been started and will automatically record its result to the * dynamic timer specified by the given config. * * @param config Config to identify a particular timer instance to update. * @param unit The unit to use when reporting values to observers. For example if sent to a * typical time series graphing system this would be the unit for the y-axis. It is generally * recommended to use base units for reporting, so {@link TimeUnit#SECONDS} is the preferred * value. */ public static Stopwatch start(MonitorConfig config, TimeUnit unit) { return INSTANCE.get(config, unit).start(); }