Search in sources :

Example 1 with MeasurableStat

use of org.apache.kafka.common.metrics.MeasurableStat in project ksql by confluentinc.

the class KsqlEngineMetrics method configureNumActiveQueries.

private Sensor configureNumActiveQueries(Metrics metrics) {
    Sensor sensor = createSensor(metrics, metricGroupName + "-active-queries");
    sensor.add(metrics.metricName("num-active-queries", this.metricGroupName, "The current number of active queries running in this engine"), new MeasurableStat() {

        @Override
        public double measure(MetricConfig metricConfig, long l) {
            return ksqlEngine.numberOfLiveQueries();
        }

        @Override
        public void record(MetricConfig metricConfig, double v, long l) {
        // We don't want to record anything, since the live queries anyway.
        }
    });
    sensor.add(metrics.metricName("num-persistent-queries", this.metricGroupName, "The current number of persistent queries running in this engine"), new MeasurableStat() {

        @Override
        public double measure(MetricConfig metricConfig, long l) {
            return ksqlEngine.numberOfPersistentQueries();
        }

        @Override
        public void record(MetricConfig metricConfig, double v, long l) {
        // No action for record since we can read the desired results directly.
        }
    });
    return sensor;
}
Also used : MetricConfig(org.apache.kafka.common.metrics.MetricConfig) MeasurableStat(org.apache.kafka.common.metrics.MeasurableStat) Sensor(org.apache.kafka.common.metrics.Sensor)

Aggregations

MeasurableStat (org.apache.kafka.common.metrics.MeasurableStat)1 MetricConfig (org.apache.kafka.common.metrics.MetricConfig)1 Sensor (org.apache.kafka.common.metrics.Sensor)1