org.apache.beam.sdk.metrics.Gauge Java Examples
The following examples show how to use
org.apache.beam.sdk.metrics.Gauge.
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: JetMetricsContainer.java From beam with Apache License 2.0 | 4 votes |
@Override public Gauge getGauge(MetricName metricName) { return gauges.computeIfAbsent(metricName, GaugeImpl::new); }
Example #2
Source File: SparkUnboundedSource.java From beam with Apache License 2.0 | 4 votes |
@Override public scala.Option<RDD<BoxedUnit>> compute(Time validTime) { // compute parent. scala.Option<RDD<Metadata>> parentRDDOpt = parent.getOrCompute(validTime); final MetricsContainerStepMapAccumulator metricsAccum = MetricsAccumulator.getInstance(); long count = 0; SparkWatermarks sparkWatermark = null; Instant globalLowWatermarkForBatch = BoundedWindow.TIMESTAMP_MIN_VALUE; Instant globalHighWatermarkForBatch = BoundedWindow.TIMESTAMP_MIN_VALUE; long maxReadDuration = 0; if (parentRDDOpt.isDefined()) { JavaRDD<Metadata> parentRDD = parentRDDOpt.get().toJavaRDD(); for (Metadata metadata : parentRDD.collect()) { count += metadata.getNumRecords(); // compute the global input watermark - advance to latest of all partitions. Instant partitionLowWatermark = metadata.getLowWatermark(); globalLowWatermarkForBatch = globalLowWatermarkForBatch.isBefore(partitionLowWatermark) ? partitionLowWatermark : globalLowWatermarkForBatch; Instant partitionHighWatermark = metadata.getHighWatermark(); globalHighWatermarkForBatch = globalHighWatermarkForBatch.isBefore(partitionHighWatermark) ? partitionHighWatermark : globalHighWatermarkForBatch; // Update metrics reported in the read final Gauge gauge = Metrics.gauge(NAMESPACE, READ_DURATION_MILLIS); final MetricsContainer container = metadata.getMetricsContainers().getContainer(stepName); try (Closeable ignored = MetricsEnvironment.scopedMetricsContainer(container)) { final long readDurationMillis = metadata.getReadDurationMillis(); if (readDurationMillis > maxReadDuration) { gauge.set(readDurationMillis); } } catch (IOException e) { throw new RuntimeException(e); } metricsAccum.value().updateAll(metadata.getMetricsContainers()); } sparkWatermark = new SparkWatermarks( globalLowWatermarkForBatch, globalHighWatermarkForBatch, new Instant(validTime.milliseconds())); // add to watermark queue. GlobalWatermarkHolder.add(inputDStreamId, sparkWatermark); } // report - for RateEstimator and visibility. report(validTime, count, sparkWatermark); return scala.Option.empty(); }
Example #3
Source File: StreamingStepMetricsContainer.java From beam with Apache License 2.0 | 4 votes |
@Override public Gauge getGauge(MetricName metricName) { return gauges.get(metricName); }
Example #4
Source File: DataflowMetricsContainer.java From beam with Apache License 2.0 | 4 votes |
@Override public Gauge getGauge(MetricName metricName) { return getCurrentContainer().getGauge(metricName); }