org.apache.flink.metrics.MeterView Java Examples
The following examples show how to use
org.apache.flink.metrics.MeterView.
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: Slf4jReporterTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testAddMeter() throws Exception { String meterName = "meter"; Meter meter = taskMetricGroup.meter(meterName, new MeterView(5)); assertTrue(reporter.getMeters().containsKey(meter)); String expectedMeterReport = reporter.filterCharacters(HOST_NAME) + delimiter + reporter.filterCharacters(TASK_MANAGER_ID) + delimiter + reporter.filterCharacters(JOB_NAME) + delimiter + reporter.filterCharacters(meterName) + ": 0.0"; reporter.report(); assertThat( testLoggerResource.getMessages(), hasItem(containsString(expectedMeterReport))); }
Example #2
Source File: TaskIOMetricGroup.java From flink with Apache License 2.0 | 6 votes |
public TaskIOMetricGroup(TaskMetricGroup parent) { super(parent); this.numBytesIn = counter(MetricNames.IO_NUM_BYTES_IN); this.numBytesOut = counter(MetricNames.IO_NUM_BYTES_OUT); this.numBytesInRate = meter(MetricNames.IO_NUM_BYTES_IN_RATE, new MeterView(numBytesIn)); this.numBytesOutRate = meter(MetricNames.IO_NUM_BYTES_OUT_RATE, new MeterView(numBytesOut)); this.numRecordsIn = counter(MetricNames.IO_NUM_RECORDS_IN, new SumCounter()); this.numRecordsOut = counter(MetricNames.IO_NUM_RECORDS_OUT, new SumCounter()); this.numRecordsInRate = meter(MetricNames.IO_NUM_RECORDS_IN_RATE, new MeterView(numRecordsIn)); this.numRecordsOutRate = meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut)); this.numBuffersOut = counter(MetricNames.IO_NUM_BUFFERS_OUT); this.numBuffersOutRate = meter(MetricNames.IO_NUM_BUFFERS_OUT_RATE, new MeterView(numBuffersOut)); this.idleTimePerSecond = meter(MetricNames.TASK_IDLE_TIME, new MeterView(new SimpleCounter())); }
Example #3
Source File: FlinkMetricContainerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testMeterMonitoringInfoUpdate() { MeterView userMeter = new MeterView(new SimpleCounter()); when(metricGroup.meter(eq("myMeter"), any(Meter.class))).thenReturn(userMeter); String namespace = "[\"key\", \"value\", \"MetricGroupType.key\", \"MetricGroupType.value\", \"60\"]"; MonitoringInfo userMonitoringInfo = new SimpleMonitoringInfoBuilder() .setUrn(MonitoringInfoConstants.Urns.USER_COUNTER) .setLabel(MonitoringInfoConstants.Labels.NAMESPACE, namespace) .setLabel(MonitoringInfoConstants.Labels.NAME, "myMeter") .setLabel(MonitoringInfoConstants.Labels.PTRANSFORM, "anyPTransform") .setInt64Value(111) .build(); assertThat(userMeter.getCount(), is(0L)); assertThat(userMeter.getRate(), is(0.0)); container.updateMetrics( "step", ImmutableList.of(userMonitoringInfo)); userMeter.update(); assertThat(userMeter.getCount(), is(111L)); assertThat(userMeter.getRate(), is(1.85)); // 111 div 60 = 1.85 }
Example #4
Source File: TaskIOMetricGroup.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public TaskIOMetricGroup(TaskMetricGroup parent) { super(parent); this.numBytesOut = counter(MetricNames.IO_NUM_BYTES_OUT); this.numBytesInLocal = counter(MetricNames.IO_NUM_BYTES_IN_LOCAL); this.numBytesInRemote = counter(MetricNames.IO_NUM_BYTES_IN_REMOTE); this.numBytesOutRate = meter(MetricNames.IO_NUM_BYTES_OUT_RATE, new MeterView(numBytesOut, 60)); this.numBytesInRateLocal = meter(MetricNames.IO_NUM_BYTES_IN_LOCAL_RATE, new MeterView(numBytesInLocal, 60)); this.numBytesInRateRemote = meter(MetricNames.IO_NUM_BYTES_IN_REMOTE_RATE, new MeterView(numBytesInRemote, 60)); this.numRecordsIn = counter(MetricNames.IO_NUM_RECORDS_IN, new SumCounter()); this.numRecordsOut = counter(MetricNames.IO_NUM_RECORDS_OUT, new SumCounter()); this.numRecordsInRate = meter(MetricNames.IO_NUM_RECORDS_IN_RATE, new MeterView(numRecordsIn, 60)); this.numRecordsOutRate = meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut, 60)); this.numBuffersOut = counter(MetricNames.IO_NUM_BUFFERS_OUT); this.numBuffersInLocal = counter(MetricNames.IO_NUM_BUFFERS_IN_LOCAL); this.numBuffersInRemote = counter(MetricNames.IO_NUM_BUFFERS_IN_REMOTE); this.numBuffersOutRate = meter(MetricNames.IO_NUM_BUFFERS_OUT_RATE, new MeterView(numBuffersOut, 60)); this.numBuffersInRateLocal = meter(MetricNames.IO_NUM_BUFFERS_IN_LOCAL_RATE, new MeterView(numBuffersInLocal, 60)); this.numBuffersInRateRemote = meter(MetricNames.IO_NUM_BUFFERS_IN_REMOTE_RATE, new MeterView(numBuffersInRemote, 60)); }
Example #5
Source File: TaskIOMetricGroup.java From flink with Apache License 2.0 | 6 votes |
public TaskIOMetricGroup(TaskMetricGroup parent) { super(parent); this.numBytesIn = counter(MetricNames.IO_NUM_BYTES_IN); this.numBytesOut = counter(MetricNames.IO_NUM_BYTES_OUT); this.numBytesInRate = meter(MetricNames.IO_NUM_BYTES_IN_RATE, new MeterView(numBytesIn, 60)); this.numBytesOutRate = meter(MetricNames.IO_NUM_BYTES_OUT_RATE, new MeterView(numBytesOut, 60)); this.numRecordsIn = counter(MetricNames.IO_NUM_RECORDS_IN, new SumCounter()); this.numRecordsOut = counter(MetricNames.IO_NUM_RECORDS_OUT, new SumCounter()); this.numRecordsInRate = meter(MetricNames.IO_NUM_RECORDS_IN_RATE, new MeterView(numRecordsIn, 60)); this.numRecordsOutRate = meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut, 60)); this.numBuffersOut = counter(MetricNames.IO_NUM_BUFFERS_OUT); this.numBuffersOutRate = meter(MetricNames.IO_NUM_BUFFERS_OUT_RATE, new MeterView(numBuffersOut, 60)); }
Example #6
Source File: ArchivedExecutionBuilder.java From flink with Apache License 2.0 | 5 votes |
public TestIOMetrics() { super( new MeterView(new TestCounter(1), 0), new MeterView(new TestCounter(2), 0), new MeterView(new TestCounter(3), 0), new MeterView(new TestCounter(4), 0)); }
Example #7
Source File: InputChannelMetrics.java From flink with Apache License 2.0 | 5 votes |
private static Counter createCounter(String name, MetricGroup ... parents) { Counter[] counters = new Counter[parents.length]; for (int i = 0; i < parents.length; i++) { counters[i] = parents[i].counter(name); parents[i].meter(name + MetricNames.SUFFIX_RATE, new MeterView(counters[i])); } return new MultiCounterWrapper(counters); }
Example #8
Source File: OperatorIOMetricGroup.java From flink with Apache License 2.0 | 5 votes |
public OperatorIOMetricGroup(OperatorMetricGroup parentMetricGroup) { super(parentMetricGroup); numRecordsIn = parentMetricGroup.counter(MetricNames.IO_NUM_RECORDS_IN); numRecordsOut = parentMetricGroup.counter(MetricNames.IO_NUM_RECORDS_OUT); numRecordsInRate = parentMetricGroup.meter(MetricNames.IO_NUM_RECORDS_IN_RATE, new MeterView(numRecordsIn)); numRecordsOutRate = parentMetricGroup.meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut)); }
Example #9
Source File: FeedbackSinkOperator.java From flink-statefun with Apache License 2.0 | 5 votes |
@Override public void open() throws Exception { super.open(); final int indexOfThisSubtask = getRuntimeContext().getIndexOfThisSubtask(); final SubtaskFeedbackKey<V> key = this.key.withSubTaskIndex(indexOfThisSubtask); FeedbackChannelBroker broker = FeedbackChannelBroker.get(); this.channel = broker.getChannel(key); // metrics MetricGroup metrics = getRuntimeContext().getMetricGroup(); SimpleCounter produced = metrics.counter("produced", new SimpleCounter()); metrics.meter("producedRate", new MeterView(produced, 60)); this.totalProduced = produced; }
Example #10
Source File: MetricFunction.java From alchemy with Apache License 2.0 | 5 votes |
default Counter createOrGet(Counter numRecordsOut, RuntimeContext runtimeContext) { if (numRecordsOut == null) { MetricGroup metricGroup = runtimeContext.getMetricGroup().addGroup(metricGroupName()); numRecordsOut = metricGroup.counter(MetricNames.IO_NUM_RECORDS_OUT); metricGroup.meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut, 60)); } return numRecordsOut; }
Example #11
Source File: FeedbackSinkOperator.java From stateful-functions with Apache License 2.0 | 5 votes |
@Override public void open() throws Exception { super.open(); final int indexOfThisSubtask = getRuntimeContext().getIndexOfThisSubtask(); final SubtaskFeedbackKey<V> key = this.key.withSubTaskIndex(indexOfThisSubtask); FeedbackChannelBroker broker = FeedbackChannelBroker.get(); this.channel = broker.getChannel(key); // metrics MetricGroup metrics = getRuntimeContext().getMetricGroup(); SimpleCounter produced = metrics.counter("produced", new SimpleCounter()); metrics.meter("producedRate", new MeterView(produced, 60)); this.totalProduced = produced; }
Example #12
Source File: Slf4jReporterTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testAddMeter() throws Exception { String meterName = "meter"; Meter meter = taskMetricGroup.meter(meterName, new MeterView(5)); assertTrue(reporter.getMeters().containsKey(meter)); String expectedMeterReport = reporter.filterCharacters(HOST_NAME) + delimiter + reporter.filterCharacters(TASK_MANAGER_ID) + delimiter + reporter.filterCharacters(JOB_NAME) + delimiter + reporter.filterCharacters(meterName) + ": 0.0"; reporter.report(); TestUtils.checkForLogString(expectedMeterReport); }
Example #13
Source File: SequenceReader.java From alibaba-flink-connectors with Apache License 2.0 | 5 votes |
public SequenceReader(AbstractParallelSourceBase<T, ?> source, InputSplitProvider provider, Configuration config) { this.sourceFunction = source; this.inputSplitProvider = provider; this.config = config; RuntimeContext context = source.getRuntimeContext(); outputCounter = context.getMetricGroup().counter(MetricUtils.METRICS_TPS + "_counter", new SimpleCounter()); tpsMetric = context.getMetricGroup().meter(MetricUtils.METRICS_TPS, new MeterView(outputCounter, 60)); }
Example #14
Source File: InputChannelMetrics.java From flink with Apache License 2.0 | 5 votes |
private static Counter createCounter(String name, MetricGroup ... parents) { Counter[] counters = new Counter[parents.length]; for (int i = 0; i < parents.length; i++) { counters[i] = parents[i].counter(name); parents[i].meter(name + MetricNames.SUFFIX_RATE, new MeterView(counters[i], 60)); } return new MultiCounterWrapper(counters); }
Example #15
Source File: OperatorIOMetricGroup.java From flink with Apache License 2.0 | 5 votes |
public OperatorIOMetricGroup(OperatorMetricGroup parentMetricGroup) { super(parentMetricGroup); numRecordsIn = parentMetricGroup.counter(MetricNames.IO_NUM_RECORDS_IN); numRecordsOut = parentMetricGroup.counter(MetricNames.IO_NUM_RECORDS_OUT); numRecordsInRate = parentMetricGroup.meter(MetricNames.IO_NUM_RECORDS_IN_RATE, new MeterView(numRecordsIn, 60)); numRecordsOutRate = parentMetricGroup.meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut, 60)); }
Example #16
Source File: Slf4jReporterTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testAddMeter() throws Exception { String meterName = "meter"; Meter meter = taskMetricGroup.meter(meterName, new MeterView(5)); assertTrue(reporter.getMeters().containsKey(meter)); String expectedMeterReport = reporter.filterCharacters(HOST_NAME) + delimiter + reporter.filterCharacters(TASK_MANAGER_ID) + delimiter + reporter.filterCharacters(JOB_NAME) + delimiter + reporter.filterCharacters(meterName) + ": 0.0"; reporter.report(); TestUtils.checkForLogString(expectedMeterReport); }
Example #17
Source File: ArchivedExecutionBuilder.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public TestIOMetrics() { super( new MeterView(new TestCounter(1), 0), new MeterView(new TestCounter(2), 0), new MeterView(new TestCounter(3), 0), new MeterView(new TestCounter(4), 0), new MeterView(new TestCounter(5), 0)); }
Example #18
Source File: OperatorIOMetricGroup.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public OperatorIOMetricGroup(OperatorMetricGroup parentMetricGroup) { super(parentMetricGroup); numRecordsIn = parentMetricGroup.counter(MetricNames.IO_NUM_RECORDS_IN); numRecordsOut = parentMetricGroup.counter(MetricNames.IO_NUM_RECORDS_OUT); numRecordsInRate = parentMetricGroup.meter(MetricNames.IO_NUM_RECORDS_IN_RATE, new MeterView(numRecordsIn, 60)); numRecordsOutRate = parentMetricGroup.meter(MetricNames.IO_NUM_RECORDS_OUT_RATE, new MeterView(numRecordsOut, 60)); }
Example #19
Source File: MetricUtils.java From alibaba-flink-connectors with Apache License 2.0 | 5 votes |
public static Meter registerOutBps(RuntimeContext context, String connectorType) { Counter bpsCounter = context.getMetricGroup().addGroup(METRIC_GROUP_SINK) .counter(METRICS_SINK_OUT_BPS + "_counter", new SimpleCounter()); String tag = ""; if (!StringUtils.isNullOrWhitespaceOnly(connectorType)) { tag = ":" + METRICS_TAG_CONNECTOR_TYPE + "=" + connectorType; } return context.getMetricGroup().addGroup(METRIC_GROUP_SINK) .meter(METRICS_SINK_OUT_BPS + tag, new MeterView(bpsCounter, 60)); }
Example #20
Source File: ParallelReader.java From alibaba-flink-connectors with Apache License 2.0 | 5 votes |
public ParallelReader( RuntimeContext context, Configuration config, long watermarkInterval, boolean tracingMetricEnabled, int sampleInterval) { this.context = context; this.config = config; this.watermarkInterval = watermarkInterval; splitPipeLen = config.getInteger(SPLIT_PIPE_LEN_CONFIG, 10); idleInterval = config.getInteger(IDLE_INTERVAL_CONFIG, 10); LOG.info("idleInterval:" + idleInterval); LOG.info("splitPipeLen:" + splitPipeLen); context.getMetricGroup().gauge(MetricUtils.METRICS_DELAY, new DelayGauge(readerRunners, DelayKind.DELAY)); context.getMetricGroup().gauge(MetricUtils.METRICS_FETCHED_DELAY, new DelayGauge(readerRunners, DelayKind.FETCHED_DELAY)); context.getMetricGroup().gauge(MetricUtils.METRICS_NO_DATA_DELAY, new DelayGauge(readerRunners, DelayKind.NO_DATA_DELAY)); outputCounter = context.getMetricGroup().counter(MetricUtils.METRICS_TPS + "_counter", new SimpleCounter()); tpsMetric = context.getMetricGroup().meter(MetricUtils.METRICS_TPS, new MeterView(outputCounter, 60)); this.tracingMetricEnabled = tracingMetricEnabled; this.sampleInterval = sampleInterval; if (this.tracingMetricEnabled) { partitionLatency = new SumAndCount(MetricUtils.METRICS_SOURCE_PARTITION_LATENCY, context.getMetricGroup()); processLatency = new SumAndCount(MetricUtils.METRICS_SOURCE_PROCESS_LATENCY, context.getMetricGroup()); partitionCount = context.getMetricGroup().gauge(MetricUtils.METRICS_SOURCE_PARTITION_COUNT, new Gauge<Integer>() { @Override public Integer getValue() { int count = 0; for (ReaderRunner runner : readerRunners) { if (!runner.finished) { count++; } } return count; } }); } }
Example #21
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void open() throws Exception { super.open(); collector = new TimestampedCollector<>(output); collector.eraseTimestamp(); internalTimerService = getInternalTimerService("window-timers", windowSerializer, this); triggerContext = new TriggerContext(); triggerContext.open(); StateDescriptor<ValueState<BaseRow>, BaseRow> windowStateDescriptor = new ValueStateDescriptor<>( "window-aggs", new BaseRowSerializer(getExecutionConfig(), accumulatorTypes)); this.windowState = (InternalValueState<K, W, BaseRow>) getOrCreateKeyedState(windowSerializer, windowStateDescriptor); if (sendRetraction) { LogicalType[] valueTypes = ArrayUtils.addAll(aggResultTypes, windowPropertyTypes); StateDescriptor<ValueState<BaseRow>, BaseRow> previousStateDescriptor = new ValueStateDescriptor<>( "previous-aggs", new BaseRowSerializer(getExecutionConfig(), valueTypes)); this.previousState = (InternalValueState<K, W, BaseRow>) getOrCreateKeyedState(windowSerializer, previousStateDescriptor); } compileGeneratedCode(); WindowContext windowContext = new WindowContext(); windowAggregator.open(new PerWindowStateDataViewStore( getKeyedStateBackend(), windowSerializer, getRuntimeContext())); if (windowAssigner instanceof MergingWindowAssigner) { this.windowFunction = new MergingWindowProcessFunction<>( (MergingWindowAssigner<W>) windowAssigner, windowAggregator, windowSerializer, allowedLateness); } else if (windowAssigner instanceof PanedWindowAssigner) { this.windowFunction = new PanedWindowProcessFunction<>( (PanedWindowAssigner<W>) windowAssigner, windowAggregator, allowedLateness); } else { this.windowFunction = new GeneralWindowProcessFunction<>( windowAssigner, windowAggregator, allowedLateness); } windowFunction.open(windowContext); // metrics this.numLateRecordsDropped = metrics.counter(LATE_ELEMENTS_DROPPED_METRIC_NAME); this.lateRecordsDroppedRate = metrics.meter( LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME, new MeterView(numLateRecordsDropped, 60)); this.watermarkLatency = metrics.gauge(WATERMARK_LATENCY_METRIC_NAME, () -> { long watermark = internalTimerService.currentWatermark(); if (watermark < 0) { return 0L; } else { return internalTimerService.currentProcessingTime() - watermark; } }); }
Example #22
Source File: FlinkFunctionTypeMetrics.java From stateful-functions with Apache License 2.0 | 4 votes |
private static SimpleCounter metered(MetricGroup metrics, String name) { SimpleCounter counter = metrics.counter(name, new SimpleCounter()); metrics.meter(name + "Rate", new MeterView(counter, 60)); return counter; }
Example #23
Source File: FlinkFunctionTypeMetrics.java From flink-statefun with Apache License 2.0 | 4 votes |
private static SimpleCounter metered(MetricGroup metrics, String name) { SimpleCounter counter = metrics.counter(name, new SimpleCounter()); metrics.meter(name + "Rate", new MeterView(counter, 60)); return counter; }
Example #24
Source File: WindowOperator.java From flink with Apache License 2.0 | 4 votes |
@Override public void open() throws Exception { super.open(); functionsClosed = false; collector = new TimestampedCollector<>(output); collector.eraseTimestamp(); internalTimerService = getInternalTimerService("window-timers", windowSerializer, this); triggerContext = new TriggerContext(); triggerContext.open(); StateDescriptor<ValueState<RowData>, RowData> windowStateDescriptor = new ValueStateDescriptor<>( "window-aggs", new RowDataSerializer(getExecutionConfig(), accumulatorTypes)); this.windowState = (InternalValueState<K, W, RowData>) getOrCreateKeyedState(windowSerializer, windowStateDescriptor); if (produceUpdates) { LogicalType[] valueTypes = ArrayUtils.addAll(aggResultTypes, windowPropertyTypes); StateDescriptor<ValueState<RowData>, RowData> previousStateDescriptor = new ValueStateDescriptor<>( "previous-aggs", new RowDataSerializer(getExecutionConfig(), valueTypes)); this.previousState = (InternalValueState<K, W, RowData>) getOrCreateKeyedState(windowSerializer, previousStateDescriptor); } compileGeneratedCode(); WindowContext windowContext = new WindowContext(); windowAggregator.open(new PerWindowStateDataViewStore( getKeyedStateBackend(), windowSerializer, getRuntimeContext())); if (windowAssigner instanceof MergingWindowAssigner) { this.windowFunction = new MergingWindowProcessFunction<>( (MergingWindowAssigner<W>) windowAssigner, windowAggregator, windowSerializer, allowedLateness); } else if (windowAssigner instanceof PanedWindowAssigner) { this.windowFunction = new PanedWindowProcessFunction<>( (PanedWindowAssigner<W>) windowAssigner, windowAggregator, allowedLateness); } else { this.windowFunction = new GeneralWindowProcessFunction<>( windowAssigner, windowAggregator, allowedLateness); } windowFunction.open(windowContext); // metrics this.numLateRecordsDropped = metrics.counter(LATE_ELEMENTS_DROPPED_METRIC_NAME); this.lateRecordsDroppedRate = metrics.meter( LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME, new MeterView(numLateRecordsDropped)); this.watermarkLatency = metrics.gauge(WATERMARK_LATENCY_METRIC_NAME, () -> { long watermark = internalTimerService.currentWatermark(); if (watermark < 0) { return 0L; } else { return internalTimerService.currentProcessingTime() - watermark; } }); }
Example #25
Source File: MetricUtils.java From alibaba-flink-connectors with Apache License 2.0 | 4 votes |
public static Meter registerOutTps(RuntimeContext context) { Counter parserCounter = context.getMetricGroup().addGroup(METRIC_GROUP_SINK) .counter(METRICS_SINK_OUT_TPS + "_counter", new SimpleCounter()); return context.getMetricGroup().addGroup(METRIC_GROUP_SINK).meter(METRICS_SINK_OUT_TPS, new MeterView(parserCounter, 60)); }
Example #26
Source File: MetricUtils.java From alibaba-flink-connectors with Apache License 2.0 | 4 votes |
public static Meter registerSinkInTps(RuntimeContext context) { Counter parserCounter = context.getMetricGroup().addGroup(METRIC_GROUP_SINK) .counter(METRICS_SINK_IN_TPS + "_counter", new SimpleCounter()); return context.getMetricGroup().addGroup(METRIC_GROUP_SINK) .meter(METRICS_SINK_IN_TPS, new MeterView(parserCounter, 60)); }