当前位置: 首页>>代码示例>>Java>>正文


Java Sampling类代码示例

本文整理汇总了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);
        }
    }));
}
 
开发者ID:blacklocus,项目名称:metrics-cloudwatch,代码行数:22,代码来源:CloudWatchReporter.java

示例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;
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:32,代码来源:MetricType.java

示例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);
}
 
开发者ID:performancecopilot,项目名称:parfait,代码行数:16,代码来源:SamplingAdapter.java

示例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;
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:13,代码来源:Metrics.java

示例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();
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:16,代码来源:MetricsRestServiceImpl.java

示例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);
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:5,代码来源:MetricAttributeHandler.java

示例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"))
			))
	});
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:61,代码来源:MetricAttributeHandler.java

示例8: samplings

import com.codahale.metrics.Sampling; //导入依赖的package包/类
Stream<MetricPart<Sampling, Object>> samplings() {
    return SAMPLING.stream()
            .filter(metricPart -> metricPredicate.test(metricPart.getSuffix()));
}
 
开发者ID:hawkular,项目名称:hawkular-dropwizard-reporter,代码行数:5,代码来源:MetricsDecomposer.java

示例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)));
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:4,代码来源:LimitCheckers.java

示例10: getMetric

import com.codahale.metrics.Sampling; //导入依赖的package包/类
@Override
Long getMetric(Sampling metric) {
    return metric.getSnapshot().getMax();
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:5,代码来源:LimitCheckers.java

示例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();
}
 
开发者ID:line,项目名称:armeria,代码行数:7,代码来源:DropwizardMetricsIntegrationTest.java

示例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());
    }
}
 
开发者ID:signalfx,项目名称:signalfx-java,代码行数:42,代码来源:AggregateMetricSenderSessionWrapper.java


注:本文中的com.codahale.metrics.Sampling类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。