public void addSampling(String name, Sampling sampling, boolean convert) { final Snapshot snapshot = sampling.getSnapshot(); maybeAdd(MEDIAN, name, convertDuration(snapshot.getMedian(), convert)); maybeAdd(PCT_75, name, convertDuration(snapshot.get75thPercentile(), convert)); maybeAdd(PCT_95, name, convertDuration(snapshot.get95thPercentile(), convert)); maybeAdd(PCT_98, name, convertDuration(snapshot.get98thPercentile(), convert)); maybeAdd(PCT_99, name, convertDuration(snapshot.get99thPercentile(), convert)); maybeAdd(PCT_999, name, convertDuration(snapshot.get999thPercentile(), convert)); if (!omitComplexGauges) { final double sum = snapshot.size() * snapshot.getMean(); final long count = (long) snapshot.size(); if (count > 0) { SourceInformation info = SourceInformation.from(sourceRegex, name); MultiSampleGaugeMeasurement measurement; try { measurement = MultiSampleGaugeMeasurement.builder(addPrefix(info.name)) .setSource(info.source) .setCount(count) .setSum(convertDuration(sum, convert)) .setMax(convertDuration(snapshot.getMax(), convert)) .setMin(convertDuration(snapshot.getMin(), convert)) .build(); } catch (IllegalArgumentException e) { log.warn("Could not create gauge", e); return; } addMeasurement(measurement); } } }
@Override public void addGaugeMeasurement(String name, Number value) { if (!checkNumber(name, value)) { return; } SourceInformation info = SourceInformation.from(sourceRegex, name); super.addGaugeMeasurement(info.source, addPrefix(info.name), value); }
@Override public void addCounterMeasurement(String name, Long value) { SourceInformation info = SourceInformation.from(sourceRegex, name); super.addCounterMeasurement(info.source, addPrefix(info.name), value); }