Java Code Examples for org.apache.hadoop.metrics2.MetricType#GAUGE

The following examples show how to use org.apache.hadoop.metrics2.MetricType#GAUGE . 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: PrometheusMetricsSink.java    From hadoop-ozone with Apache License 2.0 4 votes vote down vote up
@Override
public void putMetrics(MetricsRecord metricsRecord) {
  for (AbstractMetric metrics : metricsRecord.metrics()) {
    if (metrics.type() == MetricType.COUNTER
        || metrics.type() == MetricType.GAUGE) {

      String key = prometheusName(
          metricsRecord.name(), metrics.name());

      StringBuilder builder = new StringBuilder();
      builder.append("# TYPE ")
          .append(key)
          .append(" ")
          .append(metrics.type().toString().toLowerCase())
          .append("\n");

      StringBuilder prometheusMetricKey = new StringBuilder();
      prometheusMetricKey.append(key)
          .append("{");
      String sep = "";

      //add tags
      for (MetricsTag tag : metricsRecord.tags()) {
        String tagName = tag.name().toLowerCase();

        //ignore specific tag which includes sub-hierarchy
        if (!tagName.equals("numopenconnectionsperuser")) {
          prometheusMetricKey.append(sep)
              .append(tagName)
              .append("=\"")
              .append(tag.value())
              .append("\"");
          sep = ",";
        }
      }
      prometheusMetricKey.append("}");

      String prometheusMetricKeyAsString = prometheusMetricKey.toString();
      builder.append(prometheusMetricKeyAsString);
      builder.append(" ");
      builder.append(metrics.value());
      builder.append("\n");
      metricLines.put(prometheusMetricKeyAsString, builder.toString());

    }
  }
}
 
Example 2
Source File: MetricGaugeDouble.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 3
Source File: MetricGaugeLong.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 4
Source File: MetricGaugeInt.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 5
Source File: MetricGaugeFloat.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 6
Source File: MetricGaugeDouble.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 7
Source File: MetricGaugeLong.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 8
Source File: MetricGaugeInt.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}
 
Example 9
Source File: MetricGaugeFloat.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public MetricType type() {
  return MetricType.GAUGE;
}