Search in sources :

Example 1 with MetricsLogger

use of org.apache.beam.runners.core.metrics.MetricsLogger in project beam by apache.

the class BatchedStreamingWrite method reportStreamingApiLogging.

private void reportStreamingApiLogging(BigQueryOptions options) {
    MetricsContainer processWideContainer = MetricsEnvironment.getProcessWideContainer();
    if (processWideContainer instanceof MetricsLogger) {
        MetricsLogger processWideMetricsLogger = (MetricsLogger) processWideContainer;
        processWideMetricsLogger.tryLoggingMetrics("API call Metrics: \n", this.allowedMetricUrns, options.getBqStreamingApiLoggingFrequencySec() * 1000L);
    }
}
Also used : MetricsLogger(org.apache.beam.runners.core.metrics.MetricsLogger) MetricsContainer(org.apache.beam.sdk.metrics.MetricsContainer)

Example 2 with MetricsLogger

use of org.apache.beam.runners.core.metrics.MetricsLogger in project beam by apache.

the class StreamingDataflowWorker method main.

public static void main(String[] args) throws Exception {
    JvmInitializers.runOnStartup();
    DataflowWorkerHarnessHelper.initializeLogging(StreamingDataflowWorker.class);
    DataflowWorkerHarnessOptions options = DataflowWorkerHarnessHelper.initializeGlobalStateAndPipelineOptions(StreamingDataflowWorker.class);
    DataflowWorkerHarnessHelper.configureLogging(options);
    checkArgument(options.isStreaming(), "%s instantiated with options indicating batch use", StreamingDataflowWorker.class.getName());
    checkArgument(!DataflowRunner.hasExperiment(options, "beam_fn_api"), "%s cannot be main() class with beam_fn_api enabled", StreamingDataflowWorker.class.getSimpleName());
    // Create a non fnapi registry
    SdkHarnessRegistry sdkHarnessRegistry = SdkHarnessRegistries.emptySdkHarnessRegistry();
    StreamingDataflowWorker worker = StreamingDataflowWorker.fromDataflowWorkerHarnessOptions(options, sdkHarnessRegistry);
    // Use the MetricsLogger container which is used by BigQueryIO to periodically log process-wide
    // metrics.
    MetricsEnvironment.setProcessWideContainer(new MetricsLogger(null));
    JvmInitializers.runBeforeProcessing(options);
    worker.startStatusPages();
    worker.start();
}
Also used : MetricsLogger(org.apache.beam.runners.core.metrics.MetricsLogger) DataflowWorkerHarnessOptions(org.apache.beam.runners.dataflow.options.DataflowWorkerHarnessOptions)

Aggregations

MetricsLogger (org.apache.beam.runners.core.metrics.MetricsLogger)2 DataflowWorkerHarnessOptions (org.apache.beam.runners.dataflow.options.DataflowWorkerHarnessOptions)1 MetricsContainer (org.apache.beam.sdk.metrics.MetricsContainer)1