本文整理匯總了Java中com.codahale.metrics.Snapshot.getMean方法的典型用法代碼示例。如果您正苦於以下問題:Java Snapshot.getMean方法的具體用法?Java Snapshot.getMean怎麽用?Java Snapshot.getMean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.codahale.metrics.Snapshot
的用法示例。
在下文中一共展示了Snapshot.getMean方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: reportHistograms
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportHistograms(final long timestamp, final SortedMap<String, Histogram> histograms) {
Object[] meta = new Object[]{timestamp};
for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
String name = entry.getKey();
Histogram histogram = entry.getValue();
Snapshot snapshot = histogram.getSnapshot();
Object[] payload = new Object[13];
payload[0] = source;
payload[1] = name;
payload[2] = histogram.getCount();
payload[3] = snapshot.getMax();
payload[4] = snapshot.getMean();
payload[5] = snapshot.getMin();
payload[6] = snapshot.getStdDev();
payload[7] = snapshot.getMedian();
payload[8] = snapshot.get75thPercentile();
payload[9] = snapshot.get95thPercentile();
payload[10] = snapshot.get98thPercentile();
payload[11] = snapshot.get99thPercentile();
payload[12] = snapshot.get999thPercentile();
Event event = new Event(HISTOGRAM_STREAM_ID, timestamp, meta, null, payload);
dataPublisher.publish(event);
}
}
示例2: reportHistogram
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportHistogram(String name, Histogram histogram, long timestamp) {
if (canSkipMetric(name, histogram)) {
return;
}
final Snapshot snapshot = histogram.getSnapshot();
Object[] p = pointsHistogram[0];
p[0] = influxdb.convertTimestamp(timestamp);
p[1] = snapshot.size();
p[2] = snapshot.getMin();
p[3] = snapshot.getMax();
p[4] = snapshot.getMean();
p[5] = snapshot.getStdDev();
p[6] = snapshot.getMedian();
p[7] = snapshot.get75thPercentile();
p[8] = snapshot.get95thPercentile();
p[9] = snapshot.get99thPercentile();
p[10] = snapshot.get999thPercentile();
p[11] = histogram.getCount();
assert (p.length == COLUMNS_HISTOGRAM.length);
influxdb.appendSeries(prefix, name, ".histogram", COLUMNS_HISTOGRAM, pointsHistogram);
}
示例3: serialise
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
public MetricsHistogram serialise(String name, Histogram histo)
{
Snapshot snapshot = histo.getSnapshot();
final long count = histo.getCount();
return new MetricsHistogram(name,
count,
snapshot.size(),
snapshot.getMin(),
snapshot.getMax(),
snapshot.getStdDev(),
snapshot.getMean(),
snapshot.getMedian(),
snapshot.get75thPercentile(),
snapshot.get95thPercentile(),
snapshot.get98thPercentile(),
snapshot.get99thPercentile(),
snapshot.get999thPercentile());
}
示例4: HistogramEntity
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
public HistogramEntity(final Snapshot snapshot) {
max = snapshot.getMax();
mean = snapshot.getMean();
min = snapshot.getMin();
stdDev = snapshot.getStdDev();
median = snapshot.getMedian();
p75 = snapshot.get75thPercentile();
p95 = snapshot.get95thPercentile();
p98 = snapshot.get98thPercentile();
p99 = snapshot.get99thPercentile();
p999 = snapshot.get999thPercentile();
}
示例5: toOpStatsData
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
@Override
public OpStatsData toOpStatsData() {
long numFailed = fail.getCount();
long numSuccess = success.getCount();
Snapshot s = success.getSnapshot();
double avgLatencyMillis = s.getMean();
EnumMap<OpStatsData.Percentile, Long> percentileLongMap =
new EnumMap<OpStatsData.Percentile, Long>(OpStatsData.Percentile.class);
for (OpStatsData.Percentile percent : OpStatsData.PERCENTILESET) {
percentileLongMap.put(percent, (long) s.getValue(percent.getValue() / 100));
}
return new OpStatsData(numSuccess, numFailed, avgLatencyMillis, percentileLongMap);
}
示例6: reportTimer
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportTimer(String name, Timer timer, long timestamp, List<String> tags)
throws IOException {
final Snapshot snapshot = timer.getSnapshot();
LOG.debug("Timer[" +name + "] " + timer);
if(timer instanceof HistImplContainer) {
HistImpl take = ((HistImplContainer)timer).getHistImpl().copyAndReset();
LOG.debug("Adding Circonus Histogram to report: " + name);
request.addHistogram(new CirconusHistogram(
name, take, timestamp, host, tags));
if(suppress_bad_analytics) return;
}
double[] values = { snapshot.getMax(), snapshot.getMean(), snapshot.getMin(), snapshot.getStdDev(),
snapshot.getMedian(), snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(),
snapshot.get99thPercentile(), snapshot.get999thPercentile() };
for (int i = 0; i < STATS_EXPANSIONS.length; i++) {
if (expansions.contains(STATS_EXPANSIONS[i])) {
request.addGauge(new CirconusGauge(
appendExpansionSuffix(name, STATS_EXPANSIONS[i]),
toNumber(convertDuration(values[i])),
timestamp,
host,
tags));
}
}
reportMetered(name, timer, timestamp, tags);
}
示例7: reportHistogram
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private void reportHistogram(String name, Histogram histogram, long timestamp, List<String> tags)
throws IOException {
final Snapshot snapshot = histogram.getSnapshot();
if(histogram instanceof HistImplContainer) {
HistImpl take = ((HistImplContainer)histogram).getHistImpl().copyAndReset();
LOG.debug("Adding Circonus Histogram to report: " + name);
request.addHistogram(new CirconusHistogram(
name, take, timestamp, host, tags));
if(suppress_bad_analytics) return;
}
if (expansions.contains(Expansion.COUNT)) {
request.addGauge(new CirconusGauge(
appendExpansionSuffix(name, Expansion.COUNT),
histogram.getCount(),
timestamp,
host,
tags));
}
Number[] values = { snapshot.getMax(), snapshot.getMean(), snapshot.getMin(), snapshot.getStdDev(),
snapshot.getMedian(), snapshot.get75thPercentile(), snapshot.get95thPercentile(), snapshot.get98thPercentile(),
snapshot.get99thPercentile(), snapshot.get999thPercentile() };
for (int i = 0; i < STATS_EXPANSIONS.length; i++) {
if (expansions.contains(STATS_EXPANSIONS[i])) {
request.addGauge(new CirconusGauge(
appendExpansionSuffix(name, STATS_EXPANSIONS[i]),
toNumber(values[i]),
timestamp,
host,
tags));
}
}
}
示例8: SamplingAdapter
import com.codahale.metrics.Snapshot; //導入方法依賴的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);
}
示例9: reportHistogramSnapshot
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
private String reportHistogramSnapshot(Snapshot snapshot) {
return "min=" + snapshot.getMin() + ","
+ "max=" + snapshot.getMax() + ","
+ "mean=" + snapshot.getMean() + ","
+ "p50=" + snapshot.getMedian() + ","
+ "std=" + snapshot.getStdDev() + ","
+ "p25=" + snapshot.getValue(0.25) + ","
+ "p75=" + snapshot.get75thPercentile() + ","
+ "p95=" + snapshot.get95thPercentile() + ","
+ "p98=" + snapshot.get98thPercentile() + ","
+ "p99=" + snapshot.get99thPercentile() + ","
+ "p999=" + snapshot.get999thPercentile();
}
示例10: testVolume
import com.codahale.metrics.Snapshot; //導入方法依賴的package包/類
@Test
public void testVolume() throws SQLException {
final int iterations = 100, inserts = 100, textSize=10; // Increase iterations
for (int i = 0; i < iterations; i++) {
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("insert into METRICS_TEST(ID, TEXT, CREATED) values (?,?,?)");
for (int j = 0; j < inserts; j++) {
preparedStatement.setInt(1, i * inserts + j + 100);
preparedStatement.setString(2, randomString(textSize));
preparedStatement.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
preparedStatement.execute();
}
H2DbUtil.close(preparedStatement);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery("select count(*) from METRICS_TEST");
if (resultSet.next()) {
int count = resultSet.getInt(1);
assertThat(count, greaterThanOrEqualTo(i*inserts));
}
H2DbUtil.close(resultSet);
resultSet = statement.executeQuery("select * from METRICS_TEST order by ID asc");
readWholeResultSet(resultSet);
H2DbUtil.close(resultSet, statement);
preparedStatement = connection.prepareStatement("select * from METRICS_TEST where TEXT=? order by ID asc");
preparedStatement.setString(1, randomString(textSize));
resultSet = preparedStatement.executeQuery();
readWholeResultSet(resultSet);
H2DbUtil.close(resultSet, preparedStatement, connection);
}
metricsReporter.report(metricRegistry.getGauges(), metricRegistry.getCounters(), metricRegistry.getHistograms(), metricRegistry.getMeters(), metricRegistry.getTimers());
assertThat(metricRegistry.getTimers().size(), equalTo(
2 // connection
+2 // inserts
+5 // statements
+3 // prepared statement
));
// connection
Timer timer = metricRegistry.timer("java.sql.Connection");
assertThat(timer.getCount(), equalTo((long) iterations));
timer = metricRegistry.timer("java.sql.Connection.get");
assertThat(timer.getCount(), equalTo((long) iterations));
// statement
timer = metricRegistry.timer("java.sql.Statement");
assertThat(timer.getCount(), equalTo((long) iterations));
timer = metricRegistry.timer("java.sql.Statement.[select count(*) from metrics_test].exec");
assertThat(timer.getCount(), equalTo((long) iterations));
timer = metricRegistry.timer("java.sql.Statement.[select * from metrics_test order by id asc].exec");
assertThat(timer.getCount(), equalTo((long) iterations));
// prepared statement
timer = metricRegistry.timer("java.sql.PreparedStatement.[insert into metrics_test(id, text, created) values (?,?,?)].exec");
assertThat(timer.getCount(), equalTo((long) iterations * inserts));
timer = metricRegistry.timer("java.sql.PreparedStatement.[insert into metrics_test(id, text, created) values (?,?,?)]");
assertThat(timer.getCount(), equalTo((long) iterations));
timer = metricRegistry.timer("java.sql.PreparedStatement.[select * from metrics_test where text=? order by id asc].exec");
assertThat(timer.getCount(), equalTo((long) iterations));
Snapshot timerSnapshot = timer.getSnapshot();
double preparedStatementExecMean = timerSnapshot.getMean();
assertThat(preparedStatementExecMean, greaterThan(0.0));
assertThat(timerSnapshot.getMax(), greaterThan(0L));
assertThat(timerSnapshot.getMax(), greaterThan(timerSnapshot.getMin()));
timer = metricRegistry.timer("java.sql.PreparedStatement.[select * from metrics_test where text=? order by id asc]");
assertThat(timer.getCount(), equalTo((long) iterations));
timerSnapshot = timer.getSnapshot();
assertThat(timerSnapshot.getMean(), greaterThan(preparedStatementExecMean));
}