com.codahale.metrics.Metered Java Examples

The following examples show how to use com.codahale.metrics.Metered. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AggregateMetricSenderSessionWrapper.java    From signalfx-java with Apache License 2.0 6 votes vote down vote up
void addMetered(String baseName, Metered metered) {
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.COUNT,
            SignalFxProtocolBuffers.MetricType.CUMULATIVE_COUNTER, metered.getCount());
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_15_MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.getFifteenMinuteRate());
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_1_MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.getOneMinuteRate());
    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_5_MIN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.getFiveMinuteRate());

    addMetric(metered, baseName,
            SignalFxReporter.MetricDetails.RATE_MEAN,
            SignalFxProtocolBuffers.MetricType.GAUGE, metered.getMeanRate());
}
 
Example #2
Source File: InfluxDbReporter.java    From dropwizard-metrics-influxdb with Apache License 2.0 6 votes vote down vote up
private void reportMeter(String name, Metered meter, long now) {
    if (canSkipMetric(name, meter)) {
        return;
    }
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put("count", meter.getCount());
    fields.put("m1_rate", convertRate(meter.getOneMinuteRate()));
    fields.put("m5_rate", convertRate(meter.getFiveMinuteRate()));
    fields.put("m15_rate", convertRate(meter.getFifteenMinuteRate()));
    fields.put("mean_rate", convertRate(meter.getMeanRate()));

    if (includeMeterFields != null) {
        fields.keySet().retainAll(includeMeterFields);
    }

    influxDb.appendPoints(
        new InfluxDbPoint(
            getMeasurementName(name),
            getTags(name),
            now,
            fields));
}
 
Example #3
Source File: MetricsHandler.java    From pippo with Apache License 2.0 5 votes vote down vote up
protected void writeMetered(Metered metered, BufferedWriter writer) throws IOException {
    writeWithIndent("count = " + metered.getCount(), writer);
    writeWithIndent("mean rate = " + getRateString(metered.getMeanRate()), writer);
    writeWithIndent("1-minute rate = " + getRateString(metered.getOneMinuteRate()), writer);
    writeWithIndent("5-minute rate = " + getRateString(metered.getFiveMinuteRate()), writer);
    writeWithIndent("15-minute rate = " + getRateString(metered.getFifteenMinuteRate()), writer);
    writeWithIndent("rate unit = " + rateUnit, writer);
}
 
Example #4
Source File: CloudExitableDirectoryReaderTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setupCluster() throws Exception {
  // create one more node then shard, so that we also test the case of proxied requests.
  Builder clusterBuilder = configureCluster(3)
      .addConfig("conf", TEST_PATH().resolve("configsets").resolve("exitable-directory").resolve("conf"));
  clusterBuilder.withMetrics(true);
  clusterBuilder
      .configure();

  // pick an arbitrary node to use for our requests
  client = cluster.getRandomJetty(random()).newClient();

  CollectionAdminRequest.createCollection(COLLECTION, "conf", 2, 1)
      .processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT);
  cluster.getSolrClient().waitForState(COLLECTION, DEFAULT_TIMEOUT, TimeUnit.SECONDS,
      (n, c) -> DocCollection.isFullyActive(n, c, 2, 1));

  fiveHundredsByNode = new LinkedHashMap<>();
  int httpOk = 0;
  for (JettySolrRunner jetty: cluster.getJettySolrRunners()) {
    MetricRegistry metricRegistry = ((JettySolrRunnerWithMetrics)jetty).getMetricRegistry();
    
    httpOk += ((Metered) metricRegistry.getMetrics()
               .get("org.eclipse.jetty.servlet.ServletContextHandler.2xx-responses")).getCount();
    
    Metered old = fiveHundredsByNode.put(jetty.getNodeName(),
        (Metered) metricRegistry.getMetrics()
           .get("org.eclipse.jetty.servlet.ServletContextHandler.5xx-responses"));
    assertNull("expecting uniq nodenames",old);
  }
  assertTrue("expecting some http activity during collection creation", httpOk > 0);
  indexDocs();
}
 
Example #5
Source File: ZabbixReporter.java    From metrics-zabbix with Apache License 2.0 5 votes vote down vote up
private void addMeterDataObject(String key, Metered meter, long clock, List<DataObject> dataObjectList) {
	dataObjectList.add(toDataObject(key, ".count", meter.getCount(), clock));
	dataObjectList.add(toDataObject(key, ".meanRate", convertRate(meter.getMeanRate()), clock));
	dataObjectList.add(toDataObject(key, ".1-minuteRate", convertRate(meter.getOneMinuteRate()), clock));
	dataObjectList.add(toDataObject(key, ".5-minuteRate", convertRate(meter.getFiveMinuteRate()), clock));
	dataObjectList.add(toDataObject(key, ".15-minuteRate", convertRate(meter.getFifteenMinuteRate()), clock));
}
 
Example #6
Source File: FastForwardHttpReporter.java    From semantic-metrics with Apache License 2.0 5 votes vote down vote up
private void reportMetered(
    final BatchBuilder builder, final Metered value
) {
    final BatchBuilder b = builder.withUnit(builder.getUnit() + "/s");

    b.buildPoint("1m", value.getOneMinuteRate());
    b.buildPoint("5m", value.getFiveMinuteRate());
}
 
Example #7
Source File: WavefrontMetricsReporter.java    From dropwizard-wavefront with Apache License 2.0 5 votes vote down vote up
private void writeMetered(JsonGenerator json, Metered meter) throws IOException {
  json.writeNumberField("count", convertRate(meter.getCount()));
  json.writeNumberField("mean", convertRate(meter.getMeanRate()));
  json.writeNumberField("m1", convertRate(meter.getOneMinuteRate()));
  json.writeNumberField("m5", convertRate(meter.getFiveMinuteRate()));
  json.writeNumberField("m15", convertRate(meter.getFifteenMinuteRate()));
}
 
Example #8
Source File: DropwizardMetricsExporter.java    From dropwizard-prometheus with Apache License 2.0 5 votes vote down vote up
private void writeMetered(String dropwizardName, Metered metered) throws IOException {
    String name = sanitizeMetricName(dropwizardName);
    writer.writeSample(name, mapOf("rate", "m1"), metered.getOneMinuteRate());
    writer.writeSample(name, mapOf("rate", "m5"), metered.getFiveMinuteRate());
    writer.writeSample(name, mapOf("rate", "m15"), metered.getFifteenMinuteRate());
    writer.writeSample(name, mapOf("rate", "mean"), metered.getMeanRate());
}
 
Example #9
Source File: GraphiteReporter.java    From styx with Apache License 2.0 5 votes vote down vote up
private void reportMetered(String name, Metered meter, long timestamp) {
    MeteredPrefixes meteredPrefixes = this.meteredPrefixes.getUnchecked(name);

    doSend(meteredPrefixes.count, meter.getCount(), timestamp);
    doSend(meteredPrefixes.m1_rate, convertRate(meter.getOneMinuteRate()), timestamp);
    doSend(meteredPrefixes.m5_rate, convertRate(meter.getFiveMinuteRate()), timestamp);
    doSend(meteredPrefixes.m15_rate, convertRate(meter.getFifteenMinuteRate()), timestamp);
    doSend(meteredPrefixes.mean_rate, convertRate(meter.getMeanRate()), timestamp);
}
 
Example #10
Source File: Helper.java    From vertx-dropwizard-metrics with Apache License 2.0 5 votes vote down vote up
private static void populateMetered(JsonObject json, Metered meter, TimeUnit rateUnit) {
  double factor = rateUnit.toSeconds(1);
  json.put("count", meter.getCount());
  json.put("meanRate", meter.getMeanRate() * factor);
  json.put("oneMinuteRate", meter.getOneMinuteRate() * factor);
  json.put("fiveMinuteRate", meter.getFiveMinuteRate() * factor);
  json.put("fifteenMinuteRate", meter.getFifteenMinuteRate() * factor);
  String rate = "events/" + rateUnit.toString().toLowerCase();
  json.put("rate", rate);
}
 
Example #11
Source File: InfluxDBReporter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private void reportMetered(List<Point> points, String prefix, String name, Metered metered, long timestamp)
    throws IOException {
  reportCounter(points,prefix, name, metered, timestamp);
  String baseMetricName = getKey(prefix, name);
  points.add(buildRateAsPoint(getKey(baseMetricName, RATE_1MIN), metered.getOneMinuteRate(), timestamp));
  points.add(buildRateAsPoint(getKey(baseMetricName, RATE_5MIN), metered.getFiveMinuteRate(), timestamp));
  points.add(buildRateAsPoint(getKey(baseMetricName, RATE_15MIN), metered.getFifteenMinuteRate(), timestamp));
  points.add(buildRateAsPoint(getKey(baseMetricName, MEAN_RATE), metered.getMeanRate(), timestamp));
}
 
Example #12
Source File: GraphiteReporter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
private void reportMetered(String prefix, String name, Metered metered, long timestamp) throws IOException {
  reportCounter(prefix, name, metered, timestamp);
  String baseMetricName = getKey(prefix, name);
  pushMetricRate(getKey(baseMetricName, RATE_1MIN), metered.getOneMinuteRate(), timestamp);
  pushMetricRate(getKey(baseMetricName, RATE_5MIN), metered.getFiveMinuteRate(), timestamp);
  pushMetricRate(getKey(baseMetricName, RATE_15MIN), metered.getFifteenMinuteRate(), timestamp);
  pushMetricRate(getKey(baseMetricName, MEAN_RATE), metered.getMeanRate(), timestamp);
}
 
Example #13
Source File: MetricReportReporter.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts metrics from {@link com.codahale.metrics.Metered}.
 *
 * @param name name of the {@link com.codahale.metrics.Metered}.
 * @param meter instance of {@link com.codahale.metrics.Metered} to serialize.
 * @return a list of {@link org.apache.gobblin.metrics.Metric}.
 */
protected List<Metric> serializeMetered(String name, Metered meter) {
  return Lists.newArrayList(
    serializeValue(name, meter.getCount(), Measurements.COUNT.name()),
    serializeValue(name, meter.getMeanRate(), Measurements.MEAN_RATE.name()),
    serializeValue(name, meter.getOneMinuteRate(), Measurements.RATE_1MIN.name()),
    serializeValue(name, meter.getFiveMinuteRate(), Measurements.RATE_5MIN.name()),
    serializeValue(name, meter.getFifteenMinuteRate(), Measurements.RATE_15MIN.name())
  );
}
 
Example #14
Source File: MetricsCloudWatchReporter.java    From chassis with Apache License 2.0 4 votes vote down vote up
private void addMetered(String name, Metered metered, LinkedList<PutMetricDataRequest> requests, Date timestamp) {
    checkAndAddDatum(MetricFilter.Stat.RATE_1_MINUTE, name, metered.getOneMinuteRate(), requests, timestamp);
    checkAndAddDatum(MetricFilter.Stat.RATE_5_MINUTE, name, metered.getFiveMinuteRate(), requests, timestamp);
    checkAndAddDatum(MetricFilter.Stat.RATE_15_MINUTE, name, metered.getFifteenMinuteRate(), requests, timestamp);
    checkAndAddDatum(MetricFilter.Stat.MEAN, name, metered.getMeanRate(), requests, timestamp);
}
 
Example #15
Source File: FastForwardReporter.java    From helios with Apache License 2.0 4 votes vote down vote up
private void reportMetered(Metric metric, Metered metered) {
  //purposefully don't emit 15m as it is not very useful
  send(metric.attribute("stat", "1m").value(metered.getOneMinuteRate()));
  send(metric.attribute("stat", "5m").value(metered.getOneMinuteRate()));
}
 
Example #16
Source File: JmxMetricsReporter.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private JmxMeter(Metered metric, ObjectName objectName, TimeUnit rateUnit, String tag) {
  super(objectName, tag);
  this.metric = metric;
  this.rateFactor = rateUnit.toSeconds(1);
  this.rateUnit = ("events/" + calculateRateUnit(rateUnit)).intern();
}
 
Example #17
Source File: LimitCheckers.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
@Override
Double getMetric(Metered metric) {
    return metric.getOneMinuteRate();
}
 
Example #18
Source File: LimitCheckers.java    From haven-platform with Apache License 2.0 4 votes vote down vote up
public static Builder<Metered> whenOneMinuteRateGreaterThan(final double value) {
    return LimitCheckers.<Metered>builder().limit(new OneMinuteRate(new GreaterThan<>(value)));
}
 
Example #19
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public RatioGauge ratio1(Metered numerator, Metered denominator) {
   Preconditions.checkNotNull(numerator, "Numerator cannot be null.");
   Preconditions.checkNotNull(denominator, "Denominator cannot be null.");
   return new MeteredRatio1(numerator, denominator);
}
 
Example #20
Source File: FastForwardReporter.java    From semantic-metrics with Apache License 2.0 4 votes vote down vote up
private void reportMetered(final Metric m, Metered value) {
    final String u = getUnit(m);
    final Metric r = m.attribute("unit", u + "/s");
    send(r.attribute("stat", "1m").value(value.getOneMinuteRate()));
    send(r.attribute("stat", "5m").value(value.getFiveMinuteRate()));
}
 
Example #21
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public MeteredRatio15(Metered numerator, Metered denominator) {
   this.numerator = numerator;
   this.denominator = denominator;
}
 
Example #22
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public MeteredRatio5(Metered numerator, Metered denominator) {
   this.numerator = numerator;
   this.denominator = denominator;
}
 
Example #23
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public MeteredRatio1(Metered numerator, Metered denominator) {
   this.numerator = numerator;
   this.denominator = denominator;
}
 
Example #24
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public RatioGauge ratio15(String name, Metered numerator, Metered denominator) {
   return register(name, ratio15(numerator, denominator));
}
 
Example #25
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public RatioGauge ratio5(String name, Metered numerator, Metered denominator) {
   return register(name, ratio5(numerator, denominator));
}
 
Example #26
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public RatioGauge ratio1(String name, Metered numerator, Metered denominator) {
   return register(name, ratio1(numerator, denominator));
}
 
Example #27
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public RatioGauge ratio15(Metered numerator, Metered denominator) {
   Preconditions.checkNotNull(numerator, "Numerator cannot be null.");
   Preconditions.checkNotNull(denominator, "Denominator cannot be null.");
   return new MeteredRatio15(numerator, denominator);
}
 
Example #28
Source File: IrisMetricSet.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public RatioGauge ratio5(Metered numerator, Metered denominator) {
   Preconditions.checkNotNull(numerator, "Numerator cannot be null.");
   Preconditions.checkNotNull(denominator, "Denominator cannot be null.");
   return new MeteredRatio5(numerator, denominator);
}
 
Example #29
Source File: CloudWatchReporter.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 3 votes vote down vote up
/**
 * The rates of {@link Metered} are reported after being converted using the rate factor, which is deduced from
 * the set rate unit
 *
 * @see Timer#getSnapshot
 * @see #getRateUnit
 * @see #convertRate(double)
 */
private void processMeter(final String metricName, final Metered meter, final List<MetricDatum> metricData) {
    final String formattedRate = String.format("-rate [per-%s]", getRateUnit());
    stageMetricDatum(builder.withOneMinuteMeanRate, metricName, convertRate(meter.getOneMinuteRate()), rateUnit, "1-min-mean" + formattedRate, metricData);
    stageMetricDatum(builder.withFiveMinuteMeanRate, metricName, convertRate(meter.getFiveMinuteRate()), rateUnit, "5-min-mean" + formattedRate, metricData);
    stageMetricDatum(builder.withFifteenMinuteMeanRate, metricName, convertRate(meter.getFifteenMinuteRate()), rateUnit, "15-min-mean" + formattedRate, metricData);
    stageMetricDatum(builder.withMeanRate, metricName, convertRate(meter.getMeanRate()), rateUnit, "mean" + formattedRate, metricData);
}