Search in sources :

Example 1 with DropwizardHistogramWrapper

use of org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper in project flink by apache.

the class ScheduledDropwizardReporter method notifyOfAddedMetric.

// ------------------------------------------------------------------------
//  adding / removing metrics
// ------------------------------------------------------------------------
@Override
public void notifyOfAddedMetric(Metric metric, String metricName, MetricGroup group) {
    final String fullName = group.getMetricIdentifier(metricName, this);
    synchronized (this) {
        if (metric instanceof Counter) {
            counters.put((Counter) metric, fullName);
            registry.register(fullName, new FlinkCounterWrapper((Counter) metric));
        } else if (metric instanceof Gauge) {
            gauges.put((Gauge<?>) metric, fullName);
            registry.register(fullName, FlinkGaugeWrapper.fromGauge((Gauge<?>) metric));
        } else if (metric instanceof Histogram) {
            Histogram histogram = (Histogram) metric;
            histograms.put(histogram, fullName);
            if (histogram instanceof DropwizardHistogramWrapper) {
                registry.register(fullName, ((DropwizardHistogramWrapper) histogram).getDropwizardHistogram());
            } else {
                registry.register(fullName, new FlinkHistogramWrapper(histogram));
            }
        } else if (metric instanceof Meter) {
            Meter meter = (Meter) metric;
            meters.put(meter, fullName);
            if (meter instanceof DropwizardMeterWrapper) {
                registry.register(fullName, ((DropwizardMeterWrapper) meter).getDropwizardMeter());
            } else {
                registry.register(fullName, new FlinkMeterWrapper(meter));
            }
        } else {
            log.warn("Cannot add metric of type {}. This indicates that the reporter " + "does not support this metric type.", metric.getClass().getName());
        }
    }
}
Also used : FlinkHistogramWrapper(org.apache.flink.dropwizard.metrics.FlinkHistogramWrapper) DropwizardHistogramWrapper(org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper) Histogram(org.apache.flink.metrics.Histogram) Counter(org.apache.flink.metrics.Counter) DropwizardMeterWrapper(org.apache.flink.dropwizard.metrics.DropwizardMeterWrapper) Meter(org.apache.flink.metrics.Meter) FlinkCounterWrapper(org.apache.flink.dropwizard.metrics.FlinkCounterWrapper) FlinkMeterWrapper(org.apache.flink.dropwizard.metrics.FlinkMeterWrapper) Gauge(org.apache.flink.metrics.Gauge)

Aggregations

DropwizardHistogramWrapper (org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper)1 DropwizardMeterWrapper (org.apache.flink.dropwizard.metrics.DropwizardMeterWrapper)1 FlinkCounterWrapper (org.apache.flink.dropwizard.metrics.FlinkCounterWrapper)1 FlinkHistogramWrapper (org.apache.flink.dropwizard.metrics.FlinkHistogramWrapper)1 FlinkMeterWrapper (org.apache.flink.dropwizard.metrics.FlinkMeterWrapper)1 Counter (org.apache.flink.metrics.Counter)1 Gauge (org.apache.flink.metrics.Gauge)1 Histogram (org.apache.flink.metrics.Histogram)1 Meter (org.apache.flink.metrics.Meter)1