public Histogram registerHistogram(String name, Reservoir reservoir) { return registry.histogram(name, () -> new Histogram(reservoir)); }
/** * Creates a new {@link Timer} that uses the given {@link Reservoir} and {@link Clock}. * * @param reservoir the {@link Reservoir} implementation the timer should use * @param clock the {@link Clock} implementation the timer should use */ public Timer(Reservoir reservoir, Clock clock) { this.meter = new Meter(clock); this.clock = clock; this.histogram = new Histogram(reservoir); }
public AvgMinMaxPercentileCounter(String name) { this.name = name; this.counter = new AvgMinMaxCounter(this.name); reservoir = new ResettableUniformReservoir(); histogram = new Histogram(reservoir); }
@Override public Histogram load(String key) { Histogram histogram = new Histogram(new ExponentiallyDecayingReservoir()); metricRegistry.register(key, histogram); return histogram; } });
@Override public Histogram newMetric() { return new Histogram(new ExponentiallyDecayingReservoir()); }
@Setup(Level.Iteration) public void setup() { registry = new MetricRegistry(); histogram = registry.histogram("histogram"); histogramSlidingTimeWindow = registry.register("slidingTimeWindowHistogram", new Histogram(new SlidingTimeWindowReservoir(10, TimeUnit.SECONDS))); histogramUniform = registry.register("uniformHistogram", new Histogram(new UniformReservoir())); }
@Override public Histogram newMetric() { return new Histogram(new ExponentiallyDecayingReservoir()); }
/** * Creates a capacity monitor with the given time window. Uses the provided clock * to measure process time per message. * * @param window The length of the window to measure the capacity over * @param timeUnit The time unit of the time window * @param clock The clock used to measure the process time per message */ public CapacityMonitor(long window, TimeUnit timeUnit, Clock clock) { SlidingTimeWindowReservoir slidingTimeWindowReservoir = new SlidingTimeWindowReservoir(window, timeUnit, clock); this.processedDurationHistogram = new Histogram(slidingTimeWindowReservoir); this.timeUnit = timeUnit; this.window = window; this.clock = clock; this.capacity = new CapacityGauge(); }
public static Histogram metricSnapshot2Histogram(MetricSnapshot snapshot) { Histogram histogram; if (metricAccurateCal) { histogram = new Histogram(new ExponentiallyDecayingReservoir()); byte[] points = snapshot.get_points(); int len = snapshot.get_pointSize(); updateHistogramPoints(histogram, points, len); } else { histogram = new Histogram(new JAverageReservoir()); JAverageSnapshot averageSnapshot = (JAverageSnapshot) histogram.getSnapshot(); averageSnapshot.setMetricSnapshot(snapshot.deepCopy()); } return histogram; }
recordsProcessedCounter.inc(10l); Histogram recordSizeDistributionHistogram = new Histogram(new ExponentiallyDecayingReservoir()); recordSizeDistributionHistogram.update(1); recordSizeDistributionHistogram.update(2);
recordsProcessedCounter.inc(10l); Histogram recordSizeDistributionHistogram = new Histogram(new ExponentiallyDecayingReservoir()); recordSizeDistributionHistogram.update(1); recordSizeDistributionHistogram.update(2);
public ReconciliationState startReconciliation() { final long taskReconciliationStartedAt = System.currentTimeMillis(); if (!isRunningReconciliation.compareAndSet(false, true)) { LOG.info("Reconciliation is already running, NOT starting a new reconciliation process"); return ReconciliationState.ALREADY_RUNNING; } if (!schedulerClient.isRunning()) { LOG.trace("Not running reconciliation - no active scheduler present"); isRunningReconciliation.set(false); return ReconciliationState.NO_DRIVER; } final List<SingularityTaskId> activeTaskIds = taskManager.getActiveTaskIds(); LOG.info("Starting a reconciliation cycle - {} current active tasks", activeTaskIds.size()); schedulerClient.reconcile(Collections.emptyList()); scheduleReconciliationCheck(taskReconciliationStartedAt, activeTaskIds, 0, new Histogram(new UniformReservoir())); return ReconciliationState.STARTED; }
/** * Creates a new {@link Timer} that uses the given {@link Reservoir} and {@link Clock}. * * @param reservoir the {@link Reservoir} implementation the timer should use * @param clock the {@link Clock} implementation the timer should use */ public Timer(Reservoir reservoir, Clock clock) { this.meter = new Meter(clock); this.clock = clock; this.histogram = new Histogram(reservoir); }
public static synchronized Histogram addHistogram(FluoConfiguration config, MetricRegistry registry, String name) { Histogram histogram = registry.getHistograms().get(name); if (histogram == null) { histogram = new Histogram(getConfiguredReservoir(config)); registry.register(name, histogram); } return histogram; }
public MergeableTimerSource() { this.clock = Clock.defaultClock(); this.count = new AtomicLong(); this.histogram = new AtomicReference<>(new Histogram(new UniformReservoir())); }
@Produces private static Histogram histogram(InjectionPoint ip, MetricRegistry registry, MetricName metricName, MetricsExtension extension) { String name = metricName.of(ip); return extension.<BiFunction<String, Class<? extends Metric>, Optional<Reservoir>>>getParameter(ReservoirFunction) .flatMap(function -> function.apply(name, Histogram.class)) .map(reservoir -> registry.histogram(name, () -> new Histogram(reservoir))) .orElseGet(() -> registry.histogram(name)); }
@Override public Histogram newMetric() { return new Histogram(new SlidingWindowReservoir(size)); } @Override
public static void main(String[] args) throws InterruptedException { MetricRegistry registry = new MetricRegistry(); ConsoleReporter reporter = ConsoleReporter.forRegistry(registry).build(); reporter.start(1, TimeUnit.SECONDS); Histogram histogram = new Histogram(new ExponentiallyDecayingReservoir()); registry.register(MetricRegistry.name(HistogramExample.class, "request", "histogram"), histogram); while (true) { Thread.sleep(1000); histogram.update(random.nextInt(100000)); } } }
protected Histogram histogram(String... names) { try { return registry.histogram(nameOf(names)); } catch (Exception e) { return new Histogram(new ExponentiallyDecayingReservoir()); } }