[ 
https://issues.apache.org/jira/browse/BEAM-11213?focusedWorklogId=541492&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-541492
 ]

ASF GitHub Bot logged work on BEAM-11213:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jan/21 03:50
            Start Date: 26/Jan/21 03:50
    Worklog Time Spent: 10m 
      Work Description: tszerszen commented on a change in pull request #13743:
URL: https://github.com/apache/beam/pull/13743#discussion_r563316167



##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -213,6 +299,118 @@ public PortablePipelineResult run(RunnerApi.Pipeline 
pipeline, JobInfo jobInfo)
             result);
     metricsPusher.start();
 
+    if (eventLoggingListener != null) {
+      HashMap<String, String> driverLogs = new HashMap<String, String>();
+      MetricResults metricResults = result.metrics();
+      for (MetricResult<DistributionResult> distributionResultMetricResult :

Review comment:
       Thank you, they were add in the last commit.

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineOptions.java
##########
@@ -34,6 +34,12 @@
  */
 public interface SparkPipelineOptions extends SparkCommonPipelineOptions {
 
+  @Description("The directory to save Spark History Server logs")
+  @Default.String("/tmp/spark-events/")

Review comment:
       Ok, I've done it.

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -123,10 +140,79 @@ public PortablePipelineResult run(RunnerApi.Pipeline 
pipeline, JobInfo jobInfo)
         "Will stage {} files. (Enable logging at DEBUG level to see which 
files will be staged.)",
         pipelineOptions.getFilesToStage().size());
     LOG.debug("Staging files: {}", pipelineOptions.getFilesToStage());
-
     PortablePipelineResult result;
     final JavaSparkContext jsc = 
SparkContextFactory.getSparkContext(pipelineOptions);
 
+    EventLoggingListener eventLoggingListener;
+    String jobId = jobInfo.jobId();
+    String jobName = jobInfo.jobName();
+    Long startTime = jsc.startTime();
+    String sparkUser = jsc.sparkUser();
+    String sparkMaster = "";
+    String sparkExecutorID = "";
+    Tuple2<String, String>[] sparkConfList = jsc.getConf().getAll();
+    for (Tuple2<String, String> sparkConf : sparkConfList) {
+      if (sparkConf._1().equals("spark.master")) {
+        sparkMaster = sparkConf._2();
+      } else if (sparkConf._1().equals("spark.executor.id")) {
+        sparkExecutorID = sparkConf._2();
+      }
+    }
+    try {
+      URI eventLogDirectory = new URI(pipelineOptions.getSparkHistoryDir());
+      File eventLogDirectoryFile = new File(eventLogDirectory.getPath());
+      if (eventLogDirectoryFile.exists() && 
eventLogDirectoryFile.isDirectory()) {
+        eventLoggingListener =
+            new EventLoggingListener(
+                jobId,
+                new scala.Option<String>() {
+                  @Override
+                  public boolean isEmpty() {
+                    return false;
+                  }
+
+                  @Override
+                  public String get() {
+                    return jobName;
+                  }
+
+                  @Override
+                  public Object productElement(int i) {
+                    return null;
+                  }
+
+                  @Override
+                  public int productArity() {
+                    return 0;
+                  }
+
+                  @Override
+                  public boolean canEqual(Object o) {
+                    return false;
+                  }
+                },
+                eventLogDirectory,
+                jsc.getConf(),
+                jsc.hadoopConfiguration());
+      } else {
+        eventLoggingListener = null;
+      }
+    } catch (URISyntaxException e) {
+      e.printStackTrace();
+      eventLoggingListener = null;
+    }
+    if (eventLoggingListener != null) {

Review comment:
       Ok, the code will throw an exception if eventLogEnabled is true.

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -123,10 +140,79 @@ public PortablePipelineResult run(RunnerApi.Pipeline 
pipeline, JobInfo jobInfo)
         "Will stage {} files. (Enable logging at DEBUG level to see which 
files will be staged.)",
         pipelineOptions.getFilesToStage().size());
     LOG.debug("Staging files: {}", pipelineOptions.getFilesToStage());
-
     PortablePipelineResult result;
     final JavaSparkContext jsc = 
SparkContextFactory.getSparkContext(pipelineOptions);
 
+    EventLoggingListener eventLoggingListener;
+    String jobId = jobInfo.jobId();
+    String jobName = jobInfo.jobName();
+    Long startTime = jsc.startTime();

Review comment:
       I'll change it to Instant.now().getMillis()

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -123,10 +140,79 @@ public PortablePipelineResult run(RunnerApi.Pipeline 
pipeline, JobInfo jobInfo)
         "Will stage {} files. (Enable logging at DEBUG level to see which 
files will be staged.)",
         pipelineOptions.getFilesToStage().size());
     LOG.debug("Staging files: {}", pipelineOptions.getFilesToStage());
-
     PortablePipelineResult result;
     final JavaSparkContext jsc = 
SparkContextFactory.getSparkContext(pipelineOptions);
 
+    EventLoggingListener eventLoggingListener;
+    String jobId = jobInfo.jobId();
+    String jobName = jobInfo.jobName();
+    Long startTime = jsc.startTime();

Review comment:
       I'll change it to `Instant.now().getMillis()`

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineOptions.java
##########
@@ -34,6 +34,12 @@
  */
 public interface SparkPipelineOptions extends SparkCommonPipelineOptions {
 
+  @Description("The directory to save Spark History Server logs")
+  @Default.String("/tmp/spark-events/")

Review comment:
       It doesn't matter, however for consistency I think it would be good to 
configure it in such a way.

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -123,10 +140,79 @@ public PortablePipelineResult run(RunnerApi.Pipeline 
pipeline, JobInfo jobInfo)
         "Will stage {} files. (Enable logging at DEBUG level to see which 
files will be staged.)",
         pipelineOptions.getFilesToStage().size());
     LOG.debug("Staging files: {}", pipelineOptions.getFilesToStage());
-
     PortablePipelineResult result;
     final JavaSparkContext jsc = 
SparkContextFactory.getSparkContext(pipelineOptions);
 
+    EventLoggingListener eventLoggingListener;
+    String jobId = jobInfo.jobId();
+    String jobName = jobInfo.jobName();
+    Long startTime = jsc.startTime();
+    String sparkUser = jsc.sparkUser();
+    String sparkMaster = "";
+    String sparkExecutorID = "";
+    Tuple2<String, String>[] sparkConfList = jsc.getConf().getAll();
+    for (Tuple2<String, String> sparkConf : sparkConfList) {
+      if (sparkConf._1().equals("spark.master")) {
+        sparkMaster = sparkConf._2();
+      } else if (sparkConf._1().equals("spark.executor.id")) {
+        sparkExecutorID = sparkConf._2();

Review comment:
       For now I don't know, do you have an idea? Or could you refer someone 
who could help?

##########
File path: 
runners/spark/src/main/java/org/apache/beam/runners/spark/SparkPipelineRunner.java
##########
@@ -123,10 +140,79 @@ public PortablePipelineResult run(RunnerApi.Pipeline 
pipeline, JobInfo jobInfo)
         "Will stage {} files. (Enable logging at DEBUG level to see which 
files will be staged.)",
         pipelineOptions.getFilesToStage().size());
     LOG.debug("Staging files: {}", pipelineOptions.getFilesToStage());
-
     PortablePipelineResult result;
     final JavaSparkContext jsc = 
SparkContextFactory.getSparkContext(pipelineOptions);
 
+    EventLoggingListener eventLoggingListener;
+    String jobId = jobInfo.jobId();
+    String jobName = jobInfo.jobName();
+    Long startTime = jsc.startTime();
+    String sparkUser = jsc.sparkUser();
+    String sparkMaster = "";
+    String sparkExecutorID = "";
+    Tuple2<String, String>[] sparkConfList = jsc.getConf().getAll();
+    for (Tuple2<String, String> sparkConf : sparkConfList) {
+      if (sparkConf._1().equals("spark.master")) {
+        sparkMaster = sparkConf._2();
+      } else if (sparkConf._1().equals("spark.executor.id")) {
+        sparkExecutorID = sparkConf._2();
+      }
+    }
+    try {
+      URI eventLogDirectory = new URI(pipelineOptions.getSparkHistoryDir());
+      File eventLogDirectoryFile = new File(eventLogDirectory.getPath());
+      if (eventLogDirectoryFile.exists() && 
eventLogDirectoryFile.isDirectory()) {
+        eventLoggingListener =
+            new EventLoggingListener(
+                jobId,
+                new scala.Option<String>() {

Review comment:
       I have an error `Cannot inherit from final scala.Some` when I use 
scala.Some instead of an scala.Option.

##########
File path: runners/spark/job-server/build.gradle
##########
@@ -73,6 +73,8 @@ runShadow {
     args += 
["--clean-artifacts-per-job=${project.property('cleanArtifactsPerJob')}"]
   if (project.hasProperty('sparkMasterUrl'))
     args += ["--spark-master-url=${project.property('sparkMasterUrl')}"]
+  if (project.hasProperty('sparkHistoryDir'))

Review comment:
       Pipeline options are coded across all SDKs, therefore two extra options 
require to change pipeline options in Python SDK, Java SDK, Go SDK. My 
proposition is to keep it that way, and change every SDKs pipeline options 
gradually in other smaller PRs. Could we do it in such a way or do you insist 
on doing all these changes here in this PR?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 541492)
    Time Spent: 3h  (was: 2h 50m)

> Beam metrics should be displayed in Spark UI
> --------------------------------------------
>
>                 Key: BEAM-11213
>                 URL: https://issues.apache.org/jira/browse/BEAM-11213
>             Project: Beam
>          Issue Type: Wish
>          Components: runner-spark
>            Reporter: Kyle Weaver
>            Assignee: Tomasz Szerszen
>            Priority: P2
>              Labels: portability-spark
>          Time Spent: 3h
>  Remaining Estimate: 0h
>
> All Beam metrics are visible in the Spark UI in a single accumulator value 
> (in the "Accumulators" tab), which is a large, hard-to-read blob. Originally, 
> this blob was rendered in a bespoke format 
> (https://github.com/apache/beam/blob/ead80b469ffeeddcd8e9e5c8dc462eec0b0ffc6b/sdks/java/core/src/main/java/org/apache/beam/sdk/metrics/MetricQueryResults.java#L63-L72).
>  I changed the format to JSON so it could be easily deserialized (BEAM-9600). 
> But then an issue was filed (BEAM-10294) reporting that the new JSON format 
> was harder to read than the original bespoke format. The temporary fix was to 
> revert to the bespoke format in Spark, while allowing Flink to continue to 
> use JSON. However, if Beam metrics are only visible as an accumulator, then 
> they are also unreadable because the payloads are in binary form (BEAM-10719).
> Having metrics visible in Spark's "Metrics" tab would A) make metrics easier 
> to read (even compared to the bespoke accumulator string format), and closer 
> to what users of Beamless Spark expect, and B) free us to use the accumulator 
> however we wish for Beam internal purposes, without worrying about 
> readability.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to