org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper Java Examples
The following examples show how to use
org.apache.flink.dropwizard.metrics.DropwizardHistogramWrapper.
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: ScheduledDropwizardReporter.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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()); } } }
Example #2
Source File: ScheduledDropwizardReporter.java From flink with Apache License 2.0 | 5 votes |
@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()); } } }
Example #3
Source File: ScheduledDropwizardReporter.java From flink with Apache License 2.0 | 5 votes |
@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()); } } }
Example #4
Source File: CustomHistogramMetrics.java From flink-learning with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { //创建流运行环境 StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.getConfig().setGlobalJobParameters(ParameterTool.fromArgs(args)); env.setParallelism(1); env.addSource(new SourceFunction<Long>() { private volatile boolean isRunning = true; @Override public void run(SourceContext<Long> out) throws Exception { while (isRunning) { out.collect(Long.valueOf(Math.round(Math.random() * 100))); Thread.sleep(1000); } } @Override public void cancel() { isRunning = false; } }).map(new RichMapFunction<Long, Long>() { Histogram histogram; int index; @Override public void open(Configuration parameters) throws Exception { super.open(parameters); com.codahale.metrics.Histogram dropwizardHistogram = new com.codahale.metrics.Histogram(new SlidingWindowReservoir(500)); index = getRuntimeContext().getIndexOfThisSubtask() + 1; histogram = getRuntimeContext().getMetricGroup() .addGroup("flink-metrics-test") .histogram("histogramTest", new DropwizardHistogramWrapper(dropwizardHistogram)); } @Override public Long map(Long s) throws Exception { histogram.update(s); System.out.println("index = " + " count = " + histogram.getCount() + " max= " + histogram.getStatistics().getMax() + " min = " + histogram.getStatistics().getMin() + " mean = " + histogram.getStatistics().getMean() + " 75% = " + histogram.getStatistics().getQuantile(0.75)); return s; } }).print(); env.execute("Flink custom Histogram Metrics"); }
Example #5
Source File: CustomHistogramMetrics.java From flink-learning with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws Exception { //创建流运行环境 StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.getConfig().setGlobalJobParameters(ParameterTool.fromArgs(args)); env.setParallelism(1); env.addSource(new SourceFunction<Long>() { private volatile boolean isRunning = true; @Override public void run(SourceContext<Long> out) throws Exception { while (isRunning) { out.collect(Long.valueOf(Math.round(Math.random() * 100))); Thread.sleep(1000); } } @Override public void cancel() { isRunning = false; } }).map(new RichMapFunction<Long, Long>() { Histogram histogram; int index; @Override public void open(Configuration parameters) throws Exception { super.open(parameters); com.codahale.metrics.Histogram dropwizardHistogram = new com.codahale.metrics.Histogram(new SlidingWindowReservoir(500)); index = getRuntimeContext().getIndexOfThisSubtask() + 1; histogram = getRuntimeContext().getMetricGroup() .addGroup("flink-metrics-test") .histogram("histogramTest", new DropwizardHistogramWrapper(dropwizardHistogram)); } @Override public Long map(Long s) throws Exception { histogram.update(s); System.out.println("index = " + " count = " + histogram.getCount() + " max= " + histogram.getStatistics().getMax() + " min = " + histogram.getStatistics().getMin() + " mean = " + histogram.getStatistics().getMean() + " 75% = " + histogram.getStatistics().getQuantile(0.75)); return s; } }).print(); env.execute("Flink custom Histogram Metrics"); }