Java Code Examples for org.apache.kafka.common.metrics.KafkaMetric#value()

The following examples show how to use org.apache.kafka.common.metrics.KafkaMetric#value() . 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: DropwizardReporter.java    From kafka-dropwizard-reporter with Apache License 2.0 6 votes vote down vote up
@Override
public void metricChange(final KafkaMetric kafkaMetric) {
    LOGGER.debug("Processing a metric change for {}", kafkaMetric.metricName().toString());
    String name = dropwizardMetricName(kafkaMetric);

    Gauge<Double> gauge = new Gauge<Double>() {
        @Override
        public Double getValue() {
            return kafkaMetric.value();
        }
    };
    LOGGER.debug("Registering {}", name);
    try {
        registry.register(name, gauge);
        metricNames.add(name);
    } catch (IllegalArgumentException e) {
        LOGGER.debug("metricChange called for `{}' which was already registered, ignoring.", name);
    }
}
 
Example 2
Source File: Kafka09ConsumerClient.java    From incubator-gobblin with Apache License 2.0 5 votes vote down vote up
/**
 * Convert a {@link KafkaMetric} instance to a {@link Metric}.
 * @param kafkaMetric
 * @return
 */
private Metric kafkaToCodaHaleMetric(final KafkaMetric kafkaMetric) {
  if (log.isDebugEnabled()) {
    log.debug("Processing a metric change for {}", kafkaMetric.metricName().toString());
  }
  Gauge<Double> gauge = () -> kafkaMetric.value();
  return gauge;
}