private void reportCpuUtils(long now) { LOG.debug("Reporting CPU util."); sendCruiseControlMetric(MetricsUtils.getCpuMetric(now, _brokerId)); LOG.debug("Finished reporting CPU util."); }
@Override public void processGauge(MetricName metricName, Gauge<?> gauge, Context context) { if (MetricsUtils.isInterested(metricName)) { LOG.trace("Processing metric {} of type Gauge.", metricName); if (!(gauge.value() instanceof Number)) { throw new IllegalStateException(String.format("The value of yammer metric %s is %s, which is not a number", metricName, gauge.value())); } CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, ((Number) gauge.value()).doubleValue()); context.reporter().sendCruiseControlMetric(ccm); } }
/** * Check if a yammer metric name is an interested metric */ public static boolean isInterested(com.yammer.metrics.core.MetricName metricName) { return isInterested(metricName.getGroup(), metricName.getName(), metricName.getType(), yammerMetricScopeToTags(metricName.getScope())); }
/** * Convert a Yammer metric to a CruiseControlMetric */ public static CruiseControlMetric toCruiseControlMetric(long now, int brokerId, com.yammer.metrics.core.MetricName metricName, double value, String attribute) { CruiseControlMetric ccm = toCruiseControlMetric(now, brokerId, metricName.getName(), yammerMetricScopeToTags(metricName.getScope()), value, attribute); if (ccm == null) { throw new IllegalArgumentException(String.format("Cannot convert yammer metric %s to a Cruise Control metric for " + "broker %d at time %d for tag %s", metricName, brokerId, now, attribute)); } return ccm; }
/** * build a CruiseControlMetric object. */ private static CruiseControlMetric toCruiseControlMetric(long now, int brokerId, String name, Map<String, String> tags, double value) { return toCruiseControlMetric(now, brokerId, name, tags, value, null); }
@Override public void processCounter(MetricName metricName, Counter counter, Context context) { if (MetricsUtils.isInterested(metricName)) { LOG.warn("Not processing metric {} of type Counter.", metricName); } }
/** * Convert a Yammer metric to a CruiseControlMetric */ public static CruiseControlMetric toCruiseControlMetric(long now, int brokerId, com.yammer.metrics.core.MetricName metricName, double value) { return toCruiseControlMetric(now, brokerId, metricName, value, null); }
/** * Convert a Yammer metric to a CruiseControlMetric */ public static CruiseControlMetric toCruiseControlMetric(long now, int brokerId, com.yammer.metrics.core.MetricName metricName, double value, String attribute) { CruiseControlMetric ccm = toCruiseControlMetric(now, brokerId, metricName.getName(), yammerMetricScopeToTags(metricName.getScope()), value, attribute); if (ccm == null) { throw new IllegalArgumentException(String.format("Cannot convert yammer metric %s to a Cruise Control metric for " + "broker %d at time %d for tag %s", metricName, brokerId, now, attribute)); } return ccm; }
private void addMetricIfInterested(KafkaMetric metric) { LOG.trace("Checking Kafka metric {}", metric.metricName()); if (MetricsUtils.isInterested(metric.metricName())) { LOG.debug("Added new metric {} to Cruise Control metrics reporter.", metric.metricName()); _interestedMetrics.put(metric.metricName(), metric); } }
@Override public void processMeter(MetricName metricName, Metered metered, Context context) { if (MetricsUtils.isInterested(metricName)) { LOG.trace("Processing metric {} of type Meter.", metricName); double value; if (context.reportingInterval() <= 60000L) { value = metered.oneMinuteRate(); } else if (context.reportingInterval() <= 300000) { value = metered.fiveMinuteRate(); } else { value = metered.fifteenMinuteRate(); } CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, value); context.reporter().sendCruiseControlMetric(ccm); } }
private void reportKafkaMetrics(long now) { LOG.debug("Reporting KafkaMetrics. {}", _interestedMetrics.values()); for (KafkaMetric metric : _interestedMetrics.values()) { sendCruiseControlMetric(MetricsUtils.toCruiseControlMetric(metric, now, _brokerId)); } LOG.debug("Finished reporting KafkaMetrics."); }
/** * Check if a yammer metric name is an interested metric */ public static boolean isInterested(com.yammer.metrics.core.MetricName metricName) { return isInterested(metricName.getGroup(), metricName.getName(), metricName.getType(), yammerMetricScopeToTags(metricName.getScope())); }
/** * Check if a kafkaMetric is an interested metric. */ public static boolean isInterested(org.apache.kafka.common.MetricName metricName) { String group = metricName.group(); String name = metricName.name(); String type = metricName.tags().get(TYPE_KEY); return isInterested(group, name, type, metricName.tags()); }
private void reportCpuUtils(long now) { LOG.debug("Reporting CPU util."); sendCruiseControlMetric(MetricsUtils.getCpuMetric(now, _brokerId)); LOG.debug("Finished reporting CPU util."); }
@Override public void processHistogram(MetricName metricName, Histogram histogram, Context context) { if (MetricsUtils.isInterested(metricName)) { LOG.trace("Processing metric {} of type Histogram.", metricName); CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName,
/** * Convert a KafkaMetric to a CruiseControlMetric */ public static CruiseControlMetric toCruiseControlMetric(KafkaMetric kafkaMetric, long now, int brokerId) { org.apache.kafka.common.MetricName metricName = kafkaMetric.metricName(); CruiseControlMetric ccm = toCruiseControlMetric(now, brokerId, metricName.name(), metricName.tags(), kafkaMetric.value()); if (ccm == null) { throw new IllegalArgumentException(String.format("Cannot convert KafkaMetric %s to a Cruise Control metric for " + "broker %d at time %d", kafkaMetric.metricName(), brokerId, now)); } return ccm; }
@Override public void processCounter(MetricName metricName, Counter counter, Context context) { if (MetricsUtils.isInterested(metricName)) { LOG.warn("Not processing metric {} of type Counter.", metricName); } }
@Override public void processTimer(MetricName metricName, Timer timer, Context context) { if (MetricsUtils.isInterested(metricName)) { LOG.trace("Processing metric {} of type Timer.", metricName); CruiseControlMetric ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, context.reporter().sendCruiseControlMetric(ccm); ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, context.reporter().sendCruiseControlMetric(ccm); ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName, ccm = MetricsUtils.toCruiseControlMetric(context.time(), context.brokerId(), metricName,
/** * build a CruiseControlMetric object. */ private static CruiseControlMetric toCruiseControlMetric(long now, int brokerId, String name, Map<String, String> tags, double value) { return toCruiseControlMetric(now, brokerId, name, tags, value, null); }
private void addMetricIfInterested(KafkaMetric metric) { LOG.trace("Checking Kafka metric {}", metric.metricName()); if (MetricsUtils.isInterested(metric.metricName())) { LOG.debug("Added new metric {} to Cruise Control metrics reporter.", metric.metricName()); _interestedMetrics.put(metric.metricName(), metric); } }