public void update(long delayMs) { long delaySec = delayMs / 1000; long matchedIdx; if (levels[0] > delaySec) { matchedIdx = -1; } else { matchedIdx = levels.length - 1; for (int i = 0; i < levels.length - 1; i++) { if (levels[i] <= delaySec && delaySec < levels[i + 1]) { matchedIdx = i; break; } } } for (int i = 0; i < levels.length; i++) { if (i == matchedIdx) { gauges[i].set(1L); } else { gauges[i].set(0L); } } }
protected LongGaugeWrapper(MonitorConfig config) { gauge = new LongGauge(config); }
if(getContinuousTimeout() > 0) { MonitorConfig monitorConfig = EVCacheConfig.getInstance().getMonitorConfig(metricPrefix + "_ContinuousTimeout", DataSourceType.GAUGE, baseTags); final LongGauge cTimeouts = new LongGauge(monitorConfig); cTimeouts.set(Long.valueOf(getContinuousTimeout())); metrics.add(cTimeouts); MonitorConfig monitorConfig = EVCacheConfig.getInstance().getMonitorConfig(metricPrefix + "_WriteQ", DataSourceType.GAUGE, baseTags); final LongGauge wQueue = new LongGauge(monitorConfig); wQueue.set(Long.valueOf(writeQ.size())); metrics.add(wQueue); final LongGauge rQueue = new LongGauge(monitorConfig); rQueue.set(Long.valueOf(readQ.size())); metrics.add(rQueue);
/** * Set the current value. */ public void set(Long n) { spectatorGauge.set(n); AtomicLong number = getNumber(); number.set(n); }
public long getInflightRequests() { return inflightRequests.getValue().longValue(); }
@Test public void testGetConfig() throws Exception { LongGauge gauge = newInstance("test"); MonitorConfig expectedConfig = MonitorConfig.builder("test") .withTag(DataSourceType.GAUGE).build(); assertEquals(gauge.getConfig(), expectedConfig); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof LongGaugeWrapper)) { return false; } final LongGaugeWrapper that = (LongGaugeWrapper) o; return gauge.equals(that.gauge); }
StepCounter stepCounter = new StepCounter(MonitorConfig.builder("stepCounter").build(), manualClock); LongGauge gauge = new LongGauge(MonitorConfig.builder("longGauge").build()); basicCounter.increment(i); stepCounter.increment(i); gauge.set((long) i); List<Metric> metrics = getValue(monitors, manualClock); toRateMetricTransform.update(metrics);
public static long decrementLongGauge(LongGauge gauge) { return gauge.getNumber().decrementAndGet(); } }
public long getLiveConnections() { return liveConnections.getValue().longValue(); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof LongGaugeWrapper)) { return false; } final LongGaugeWrapper that = (LongGaugeWrapper) o; return gauge.equals(that.gauge); }
@Override public void run() { try { Current current = measure(); if (current != null) { LOG.debug("reservedMemory={}, maxMemory={}", current.reservedMemory, current.maxMemory); reservedMemoryGauge.set(current.reservedMemory); maxMemoryGauge.set(current.maxMemory); } } catch (Throwable t) { LOG.warn("Error in DirectMemoryMonitor task.", t); } }
public ThresholdLevelsMetric(Object owner, String prefix, long[] levels) { this.levels = levels; this.gauges = new LongGauge[levels.length]; for (int i = 0; i < levels.length; i++) { String name = prefix + String.format("%05d", levels[i]); MonitorConfig config = new MonitorConfig.Builder(name) .withTag("class", owner.getClass().getName()) .build(); gauges[i] = new LongGauge(config); try { DefaultMonitorRegistry.getInstance().register(gauges[i]); } catch (Throwable e) { logger.warn("Cannot register metric {}", name, e); } } }
public static long decrementLongGauge(LongGauge gauge) { return gauge.getNumber().decrementAndGet(); } }
public long getPendingFlushes() { return pendingFlushes.getValue().longValue(); }