@Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>(); CounterMetricFamily blockingCounter = new CounterMetricFamily(SINK_BLOCKING_TIME, SINK_BLOCK_TIME_HELP, DEST_LABELS_LIST); for (SinkMetricsHolder smh : instances.values()) { blockingCounter.addMetric(smh.destLabelValues, (smh.eventsSinkBlockingTime.doubleValue() / NANO_PER_MILLI)); } mfs.add(blockingCounter); return mfs; }
private void singleCollect(CounterMetricFamily bytesCounter, CounterMetricFamily blockingCounter, GaugeMetricFamily modeGauge, ParserMetricsHolder holder) { if (holder.isParallel) { blockingCounter.addMetric(holder.parserLabelValues, (holder.eventsPublishBlockingTime.doubleValue() / NANO_PER_MILLI)); } modeGauge.addMetric(holder.modeLabelValues, 1); bytesCounter.addMetric(holder.parserLabelValues, holder.receivedBinlogBytes.doubleValue()); }
@JmxGetter(name = "avgWaitTimeMs", description = "The avg. ms of wait time to acquire a connection.") public double getAvgWaitTimeMs() { return this.avgWaitNs.doubleValue() / Time.NS_PER_MS; }
private long caclSleepTime(MockInfo info) { double rMean = info.totalSleepTime.doubleValue() / info.callNum.get(); long sleepTime; int n = ThreadLocalRandom.current().nextInt(1000); long delta = (long) (rMean - info.mean + 1); if (n < 900) { sleepTime = info.p90; } else if (900 <= n && n < 990) { sleepTime = info.p99; } else if (990 <= n && n < 999) { sleepTime = info.p999; } else { sleepTime = info.p999 + 1; } // Use 0ms to offset the mean time. sleepTime = delta > 0 ? 0 : sleepTime; info.totalSleepTime.addAndGet(sleepTime); // Throw runtimeException when errorRate is defined. if (info.errorRate != 0) { int rate = 1; while (info.errorRate * rate < 1) { rate *= 10; } if (ThreadLocalRandom.current().nextInt(rate) == 1) { throw new RuntimeException(); } } return sleepTime; }
@Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>(); GaugeMetricFamily delay = new GaugeMetricFamily(DELAY, DELAY_HELP, DEST_LABELS_LIST); CounterMetricFamily transactions = new CounterMetricFamily(TRANSACTION, TRANSACTION_HELP, DEST_LABELS_LIST); for (EntryMetricsHolder emh : instances.values()) { long now = System.currentTimeMillis(); long latest = emh.latestExecTime.get(); // execTime > now,delay显示为0 long d = (now >= latest) ? (now - latest) : 0; delay.addMetric(emh.destLabelValues, d); transactions.addMetric(emh.destLabelValues, emh.transactionCounter.doubleValue()); } mfs.add(delay); mfs.add(transactions); return mfs; }
public BrokerConnectionEventHandler() { QMon.activeClientCount(() -> brokerStats.getActiveClientConnectionCount().doubleValue()); }
for (StoreMetricsHolder smh : instances.values()) { final boolean isMem = smh.batchMode.isMemSize(); put.addMetric(smh.destLabelValues, smh.putSeq.doubleValue()); ack.addMetric(smh.destLabelValues, smh.ackSeq.doubleValue()); long pet = smh.putExecTime.get(); long ad = (now >= aet) ? (now - aet) : 0; ackDelay.addMetric(smh.destLabelValues, ad); putRows.addMetric(smh.destLabelValues, smh.putTableRows.doubleValue()); getRows.addMetric(smh.destLabelValues, smh.getTableRows.doubleValue()); ackRows.addMetric(smh.destLabelValues, smh.ackTableRows.doubleValue()); store.addMetric(smh.storeLabelValues, 1); if (isMem) { hasMem = true; putMem.addMetric(smh.destLabelValues, smh.putMemSize.doubleValue()); ackMem.addMetric(smh.destLabelValues, smh.ackMemSize.doubleValue());
@Override public List<MetricFamilySamples> collect() { List<MetricFamilySamples> mfs = new ArrayList<MetricFamilySamples>(); CounterMetricFamily blockingCounter = new CounterMetricFamily(SINK_BLOCKING_TIME, SINK_BLOCK_TIME_HELP, DEST_LABELS_LIST); for (SinkMetricsHolder smh : instances.values()) { blockingCounter.addMetric(smh.destLabelValues, (smh.eventsSinkBlockingTime.doubleValue() / NANO_PER_MILLI)); } mfs.add(blockingCounter); return mfs; }
private void singleCollect(CounterMetricFamily bytesCounter, CounterMetricFamily blockingCounter, GaugeMetricFamily modeGauge, ParserMetricsHolder holder) { if (holder.isParallel) { blockingCounter.addMetric(holder.parserLabelValues, (holder.eventsPublishBlockingTime.doubleValue() / NANO_PER_MILLI)); } modeGauge.addMetric(holder.modeLabelValues, 1); bytesCounter.addMetric(holder.parserLabelValues, holder.receivedBinlogBytes.doubleValue()); }
/** The binary {@code lessThan} operator. This is the equivalent to * the Java {@code <} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left<right} */ @Pure @Inline(value = "($1.doubleValue() < $2.doubleValue())", constantExpression = true) public static boolean operator_lessThan(AtomicLong left, Number right) { return left.doubleValue() < right.doubleValue(); }
/** The binary {@code lessEqualsThan} operator. This is the equivalent * to the Java {@code <=} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left<=right} */ @Pure @Inline(value = "($1.doubleValue() <= $2.doubleValue())", constantExpression = true) public static boolean operator_lessEqualsThan(AtomicLong left, Number right) { return left.doubleValue() <= right.doubleValue(); }
/** The binary {@code greaterThan} operator. This is the equivalent * to the Java {@code >} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left>right} */ @Pure @Inline(value = "($1.doubleValue() > $2.doubleValue())", constantExpression = true) public static boolean operator_greaterThan(AtomicLong left, Number right) { return left.doubleValue() > right.doubleValue(); }
/** The binary {@code lessThan} operator. This is the equivalent to * the Java {@code <} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left<right} */ @Pure @Inline(value = "($1.doubleValue() < $2)", constantExpression = true) public static boolean operator_lessThan(AtomicLong left, double right) { return left.doubleValue() < right; }
/** The binary {@code lessEqualsThan} operator. This is the equivalent * to the Java {@code <=} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left<=right} */ @Pure @Inline(value = "($1.doubleValue() <= $2)", constantExpression = true) public static boolean operator_lessEqualsThan(AtomicLong left, double right) { return left.doubleValue() <= right; }
/** The binary {@code greaterThan} operator. This is the equivalent * to the Java {@code >} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left>right} */ @Pure @Inline(value = "($1.doubleValue() > $2)", constantExpression = true) public static boolean operator_greaterThan(AtomicLong left, double right) { return left.doubleValue() > right; }
/** The binary {@code notEquals} operator. This is the equivalent * to the Java {@code !=} operator. This function is null-safe. * * @param left a number. * @param right a number. * @return {@code left!=right} */ @Pure @Inline(value = "($1 == null ? false : ($1.doubleValue() != $2))", constantExpression = true) public static boolean operator_notEquals(AtomicLong left, double right) { return left == null ? false : left.doubleValue() != right; }
/** The binary {@code lessThan} operator. This is the equivalent to * the Java {@code <} operator. This function is not null-safe. * * @param left a number. * @param right a number. * @return {@code left<right} */ @Pure @Inline(value = "($1.doubleValue() < $2)", constantExpression = true) public static boolean operator_lessThan(AtomicLong left, float right) { return left.doubleValue() < right; }
/** * @see stream.statistics.StatisticsService#getStatistics() */ @Override public Statistics getStatistics() { Statistics stats = new Statistics(); stats.put(key, memoryUsed.doubleValue()); return stats; }
/** * @see stream.statistics.StatisticsService#getStatistics() */ @Override public Statistics getStatistics() { Statistics stats = new Statistics(); stats.put(key, memoryUsed.doubleValue()); return stats; }
@Test public void testGaugeHelpersWithCustomFunction2() { AtomicLong al1 = new AtomicLong(1L); Registry r = new DefaultRegistry(new ManualClock(40, 0)); ToDoubleFunction<AtomicLong> f = (obj) -> (r.clock().wallTime() - obj.doubleValue()) / 1000.0; AtomicLong v1 = r.gauge("foo", al1, f); Assertions.assertSame(v1, al1); Id id1 = r.createId("foo"); assertGaugeValue(r, id1, 39.0 / 1000.0); }