本文整理汇总了Java中com.codahale.metrics.Sampling类的典型用法代码示例。如果您正苦于以下问题:Java Sampling类的具体用法?Java Sampling怎么用?Java Sampling使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sampling类属于com.codahale.metrics包,在下文中一共展示了Sampling类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reportSampling
import com.codahale.metrics.Sampling; //导入依赖的package包/类
/**
* @param rescale the submitted sum by this multiplier. 1.0 is the identity (no rescale).
*/
void reportSampling(Map.Entry<String, ? extends Sampling> entry, String typeDimValue, double rescale, List<MetricDatum> data) {
Sampling metric = entry.getValue();
Snapshot snapshot = metric.getSnapshot();
double scaledSum = sum(snapshot.getValues()) * rescale;
final StatisticSet statisticSet = new StatisticSet()
.withSum(scaledSum)
.withSampleCount((double) snapshot.size())
.withMinimum((double) snapshot.getMin() * rescale)
.withMaximum((double) snapshot.getMax() * rescale);
DemuxedKey key = new DemuxedKey(appendGlobalDimensions(entry.getKey()));
Iterables.addAll(data, key.newDatums(typeDimName, typeDimValue, new Function<MetricDatum, MetricDatum>() {
@Override
public MetricDatum apply(MetricDatum datum) {
return datum.withStatisticValues(statisticSet);
}
}));
}
示例2: invoke
import com.codahale.metrics.Sampling; //导入依赖的package包/类
/**
* {@inheritDoc}
* @see com.heliosapm.streams.jmx.metrics.MetricType.AttributeAdapter#invoke(com.codahale.metrics.Metric)
*/
@Override
public Object invoke(final Metric metric) {
final Sampling s = (Sampling)metric;
switch(this) {
case MAX:
return s.getSnapshot().getMax();
case MEAN:
return s.getSnapshot().getMean();
case MEDIAN:
return s.getSnapshot().getMedian();
case MIN:
return s.getSnapshot().getMin();
case PCT75:
return s.getSnapshot().get75thPercentile();
case PCT95:
return s.getSnapshot().get95thPercentile();
case PCT98:
return s.getSnapshot().get98thPercentile();
case PCT99:
return s.getSnapshot().get99thPercentile();
case PCT999:
return s.getSnapshot().get999thPercentile();
case STDDEV:
return s.getSnapshot().getStdDev();
}
return null;
}
示例3: SamplingAdapter
import com.codahale.metrics.Sampling; //导入依赖的package包/类
public SamplingAdapter(Sampling samplingMetric, String name, String description, Unit<?> unit) {
this.samplingMetric = samplingMetric;
Snapshot snapshot = samplingMetric.getSnapshot();
this.mean = new NonSelfRegisteringSettableValue<>(name(name, "mean"), description + " - Mean", unit, snapshot.getMean(), ValueSemantics.FREE_RUNNING);
this.seventyFifthPercentile = new NonSelfRegisteringSettableValue<>(name(name, "seventyfifth"), description + " - 75th Percentile of recent data", unit, snapshot.get75thPercentile(), ValueSemantics.FREE_RUNNING);
this.ninetyFifthPercentile = new NonSelfRegisteringSettableValue<>(name(name, "ninetyfifth"), description + " - 95th Percentile of recent data", unit, snapshot.get95thPercentile(), ValueSemantics.FREE_RUNNING);
this.ninetyEighthPercentile = new NonSelfRegisteringSettableValue<>(name(name, "ninetyeighth"), description + " - 98th Percentile of recent data", unit, snapshot.get98thPercentile(), ValueSemantics.FREE_RUNNING);
this.ninetyNinthPercentile = new NonSelfRegisteringSettableValue<>(name(name, "ninetynineth"), description + " - 99th Percentile of recent data", unit, snapshot.get99thPercentile(), ValueSemantics.FREE_RUNNING);
this.threeNinesPercentile = new NonSelfRegisteringSettableValue<>(name(name, "threenines"), description + " - 99.9th Percentile of recent data", unit, snapshot.get999thPercentile(), ValueSemantics.FREE_RUNNING);
this.median = new NonSelfRegisteringSettableValue<>(name(name, "median"), description + " - Median", unit, snapshot.getMedian(), ValueSemantics.FREE_RUNNING);
this.max = new NonSelfRegisteringSettableValue<>(name(name, "max"), description + " - Maximum", unit, snapshot.getMax(), ValueSemantics.MONOTONICALLY_INCREASING);
this.min = new NonSelfRegisteringSettableValue<>(name(name, "min"), description + " - Minimum", unit, snapshot.getMin(), ValueSemantics.FREE_RUNNING);
this.stddev = new NonSelfRegisteringSettableValue<>(name(name, "stddev"), description + " - Standard Deviation", unit, snapshot.getStdDev(), ValueSemantics.FREE_RUNNING);
}
示例4: toSnapshot
import com.codahale.metrics.Sampling; //导入依赖的package包/类
private static Snapshot toSnapshot( String name, Metric value ) {
Snapshot snapshot = new Snapshot( name );
if( value instanceof Sampling )
snapshot.mean = ( ( Sampling ) value ).getSnapshot().getMean();
if( value instanceof Metered )
snapshot.meanRate = ( ( Metered ) value ).getMeanRate();
if( value instanceof Counting )
snapshot.count = ( ( Counting ) value ).getCount();
if( value instanceof Gauge )
snapshot.count = ( ( Number ) ( ( Gauge ) value ).getValue() ).longValue();
return snapshot;
}
示例5: getIndex
import com.codahale.metrics.Sampling; //导入依赖的package包/类
@Override
public String getIndex()
{
TemplateCall call = templater.template(PREFIX + "index.html");
call.set("gauges", registry.getGauges().entrySet());
call.set("counters", this.<Counting>combine(registry.getCounters(),
registry.getMeters(),
registry.getTimers(),
registry.getHistograms()).entrySet());
call.set("meters", this.<Metered>combine(registry.getMeters(), registry.getTimers()).entrySet());
call.set("histograms", this.<Sampling>combine(registry.getHistograms(), registry.getTimers()).entrySet());
return call.process();
}
示例6: SnapshotAttributeGetter
import com.codahale.metrics.Sampling; //导入依赖的package包/类
SnapshotAttributeGetter(final Sampling target, final String methodName) {
this.target = target.getSnapshot();
method = PrivateAccessor.findMethodFromClass(Snapshot.class, methodName);
}
示例7: minfo
import com.codahale.metrics.Sampling; //导入依赖的package包/类
@Override
public NVP<Metric, MBeanAttributeInfo[]> minfo(final Metric metric) {
return new NVP<Metric, MBeanAttributeInfo[]>(metric, new MBeanAttributeInfo[]{
new MBeanAttributeInfo("HistogramCount", "long", "The number of values that have been recorded", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "getCount"))
.fput("metricType", new AttributeGetter(metric, "counter"))
)),
new MBeanAttributeInfo("75thPct", "double", "The value at the 75th percentile in the distribution.", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "get75thPercentile"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("95thPct", "double", "The value at the 95th percentile in the distribution.", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "get95thPercentile"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("98thPct", "double", "The value at the 98th percentile in the distribution.", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "get98thPercentile"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("99thPct", "double", "The value at the 99th percentile in the distribution.", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "get99thPercentile"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("999thPct", "double", "The value at the 99.9th percentile in the distribution.", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "get999thPercentile"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("HistogramMax", "double", "The highest value in the snapshot", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "getMax"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("HistogramMin", "double", "The lowest value in the snapshot", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "getMin"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("HistogramMean", "double", "The arithmetic mean of values in the snapshot", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "getMean"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("HistogramMedian", "double", "The median of values in the snapshot", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "getMedian"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
)),
new MBeanAttributeInfo("HistogramStdDev", "double", "The standard deviation of values in the snapshot", true, false, false, new ImmutableDescriptor(FluentMap.newMap(String.class, Object.class)
.fput("metricClass", com.codahale.metrics.Histogram.class.getName())
.fput("invoker", new AttributeGetter(metric, "getStdDev"))
.fput("metricType", new SnapshotAttributeGetter((Sampling)metric, "gauge"))
))
});
}
示例8: samplings
import com.codahale.metrics.Sampling; //导入依赖的package包/类
Stream<MetricPart<Sampling, Object>> samplings() {
return SAMPLING.stream()
.filter(metricPart -> metricPredicate.test(metricPart.getSuffix()));
}
示例9: whenMaxValueGreaterThan
import com.codahale.metrics.Sampling; //导入依赖的package包/类
public static Builder<Sampling> whenMaxValueGreaterThan(final long value) {
return LimitCheckers.<Sampling>builder().limit(new MaxSnapshotValue(new GreaterThan<>(value)));
}
示例10: getMetric
import com.codahale.metrics.Sampling; //导入依赖的package包/类
@Override
Long getMetric(Sampling metric) {
return metric.getSnapshot().getMax();
}
示例11: assertSummary
import com.codahale.metrics.Sampling; //导入依赖的package包/类
private static void assertSummary(Map<String, ?> map, String property, int expectedCount) {
assertThat(((Counting) map.get(clientMetricName(property))).getCount()).isEqualTo(expectedCount);
assertThat(((Sampling) map.get(clientMetricName(property))).getSnapshot().getMean()).isPositive();
assertThat(((Counting) map.get(serverMetricName(property))).getCount()).isEqualTo(expectedCount);
assertThat(((Sampling) map.get(serverMetricName(property))).getSnapshot().getMean()).isPositive();
}
示例12: addSampling
import com.codahale.metrics.Sampling; //导入依赖的package包/类
private void addSampling(String baseName, Sampling sampling) {
Metric metric = (Metric)sampling;
final Snapshot snapshot = sampling.getSnapshot();
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.MEDIAN,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMedian());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.PERCENT_75,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get75thPercentile());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.PERCENT_95,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get95thPercentile());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.PERCENT_98,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get98thPercentile());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.PERCENT_99,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get99thPercentile());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.PERCENT_999,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.get999thPercentile());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.MAX,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMax());
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.MIN,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMin());
// These are slower to calculate. Only calculate if we need.
if (detailsToAdd.contains(SignalFxReporter.MetricDetails.STD_DEV)) {
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.STD_DEV,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getStdDev());
}
if (detailsToAdd.contains(SignalFxReporter.MetricDetails.MEAN)) {
addMetric(metric, baseName,
SignalFxReporter.MetricDetails.MEAN,
SignalFxProtocolBuffers.MetricType.GAUGE, snapshot.getMean());
}
}