Search in sources :

Example 1 with HistogramStatistics

use of org.apache.flink.metrics.HistogramStatistics in project flink by apache.

the class StatsDReporter method reportHistogram.

private void reportHistogram(final String name, final Histogram histogram) {
    if (histogram != null) {
        HistogramStatistics statistics = histogram.getStatistics();
        if (statistics != null) {
            send(prefix(name, "count"), String.valueOf(histogram.getCount()));
            send(prefix(name, "max"), String.valueOf(statistics.getMax()));
            send(prefix(name, "min"), String.valueOf(statistics.getMin()));
            send(prefix(name, "mean"), String.valueOf(statistics.getMean()));
            send(prefix(name, "stddev"), String.valueOf(statistics.getStdDev()));
            send(prefix(name, "p50"), String.valueOf(statistics.getQuantile(0.5)));
            send(prefix(name, "p75"), String.valueOf(statistics.getQuantile(0.75)));
            send(prefix(name, "p95"), String.valueOf(statistics.getQuantile(0.95)));
            send(prefix(name, "p98"), String.valueOf(statistics.getQuantile(0.98)));
            send(prefix(name, "p99"), String.valueOf(statistics.getQuantile(0.99)));
            send(prefix(name, "p999"), String.valueOf(statistics.getQuantile(0.999)));
        }
    }
}
Also used : HistogramStatistics(org.apache.flink.metrics.HistogramStatistics)

Example 2 with HistogramStatistics

use of org.apache.flink.metrics.HistogramStatistics in project flink by apache.

the class MetricGroupRegistrationTest method testMetricInstantiation.

/**
	 * Verifies that group methods instantiate the correct metric with the given name.
	 */
@Test
public void testMetricInstantiation() {
    Configuration config = new Configuration();
    config.setString(ConfigConstants.METRICS_REPORTERS_LIST, "test");
    config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, TestReporter1.class.getName());
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
    MetricGroup root = new TaskManagerMetricGroup(registry, "host", "id");
    Counter counter = root.counter("counter");
    assertEquals(counter, TestReporter1.lastPassedMetric);
    assertEquals("counter", TestReporter1.lastPassedName);
    Gauge<Object> gauge = root.gauge("gauge", new Gauge<Object>() {

        @Override
        public Object getValue() {
            return null;
        }
    });
    Assert.assertEquals(gauge, TestReporter1.lastPassedMetric);
    assertEquals("gauge", TestReporter1.lastPassedName);
    Histogram histogram = root.histogram("histogram", new Histogram() {

        @Override
        public void update(long value) {
        }

        @Override
        public long getCount() {
            return 0;
        }

        @Override
        public HistogramStatistics getStatistics() {
            return null;
        }
    });
    Assert.assertEquals(histogram, TestReporter1.lastPassedMetric);
    assertEquals("histogram", TestReporter1.lastPassedName);
    registry.shutdown();
}
Also used : Histogram(org.apache.flink.metrics.Histogram) Counter(org.apache.flink.metrics.Counter) Configuration(org.apache.flink.configuration.Configuration) MetricRegistryConfiguration(org.apache.flink.runtime.metrics.MetricRegistryConfiguration) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) MetricGroup(org.apache.flink.metrics.MetricGroup) HistogramStatistics(org.apache.flink.metrics.HistogramStatistics) Test(org.junit.Test)

Example 3 with HistogramStatistics

use of org.apache.flink.metrics.HistogramStatistics in project flink by apache.

the class MetricDumpSerialization method serializeHistogram.

private static void serializeHistogram(DataOutput out, QueryScopeInfo info, String name, Histogram histogram) throws IOException {
    HistogramStatistics stat = histogram.getStatistics();
    long min = stat.getMin();
    long max = stat.getMax();
    double mean = stat.getMean();
    double median = stat.getQuantile(0.5);
    double stddev = stat.getStdDev();
    double p75 = stat.getQuantile(0.75);
    double p90 = stat.getQuantile(0.90);
    double p95 = stat.getQuantile(0.95);
    double p98 = stat.getQuantile(0.98);
    double p99 = stat.getQuantile(0.99);
    double p999 = stat.getQuantile(0.999);
    serializeMetricInfo(out, info);
    out.writeUTF(name);
    out.writeLong(min);
    out.writeLong(max);
    out.writeDouble(mean);
    out.writeDouble(median);
    out.writeDouble(stddev);
    out.writeDouble(p75);
    out.writeDouble(p90);
    out.writeDouble(p95);
    out.writeDouble(p98);
    out.writeDouble(p99);
    out.writeDouble(p999);
}
Also used : HistogramStatistics(org.apache.flink.metrics.HistogramStatistics)

Aggregations

HistogramStatistics (org.apache.flink.metrics.HistogramStatistics)3 Configuration (org.apache.flink.configuration.Configuration)1 Counter (org.apache.flink.metrics.Counter)1 Histogram (org.apache.flink.metrics.Histogram)1 MetricGroup (org.apache.flink.metrics.MetricGroup)1 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)1 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)1 Test (org.junit.Test)1