如何使用JavaSDK查找Google数据流中每个步骤的总执行时间

如何使用JavaSDK查找Google数据流中每个步骤的总执行时间,java,google-cloud-dataflow,apache-beam,Java,Google Cloud Dataflow,Apache Beam,我正在使用Apache-beam-2.3.0在Google云平台上运行数据流作业。每个数据流作业有5个步骤。我想使用JavaSDK跟踪完成作业中每个步骤所花费的时间 Pipeline pipeline = Pipeline.create(options); for(int i=0; i<5; i++) { PCollection<String> csv = pipeline.apply(transform1); csv.apply(transform2); } pipeli

我正在使用Apache-beam-2.3.0在Google云平台上运行数据流作业。每个数据流作业有5个步骤。我想使用JavaSDK跟踪完成作业中每个步骤所花费的时间

Pipeline pipeline = Pipeline.create(options);

for(int i=0; i<5; i++) {
PCollection<String> csv = pipeline.apply(transform1);
csv.apply(transform2);
}

pipeline.run().waitUntilFinish();
如何使用PipelineResult测量完成作业中每个步骤所需的时间,您可以使用查看步骤级别的指标。例如:

Pipeline p = ...;
 p.apply("create1", Create.of("hello")).apply("myStepName1", ParDo.of(new SomeDoFn()));
 p.apply("create2", Create.of("world")).apply("myStepName2", ParDo.of(new SomeDoFn()));
 PipelineResult result = p.run();
 MetricResults metrics = result.metrics();
 MetricQueryResults metricResults = metrics.queryMetrics(new MetricsFilter.Builder()
     .addNameFilter("my-counter")
     .addStepFilter("myStepName1").addStepFilter("myStepName2")
     .build());
 Iterable<MetricResult<Long>> counters = metricResults.counters();
 // counters should contain the value of my-counter reported from each of the ParDo
 // applications.

在这种情况下,您可以定义一个计数器,而不是一个计数器。这里有一些例子

这里的任何输入都是非常感谢的