{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/87687846","pull_request_review_id":8293967,"id":87687846,"diff_hunk":"@@ -2578,26 +2579,38 @@ private[util] object CallerContext extends Logging {\n  * @param taskAttemptNumber task attempt id\n  */\n private[spark] class CallerContext(\n-   from: String,\n-   appId: Option[String] = None,\n-   appAttemptId: Option[String] = None,\n-   jobId: Option[Int] = None,\n-   stageId: Option[Int] = None,\n-   stageAttemptId: Option[Int] = None,\n-   taskId: Option[Long] = None,\n-   taskAttemptNumber: Option[Int] = None) extends Logging {\n-\n-   val appIdStr = if (appId.isDefined) s\"_${appId.get}\" else \"\"\n-   val appAttemptIdStr = if (appAttemptId.isDefined) s\"_${appAttemptId.get}\" else \"\"\n-   val jobIdStr = if (jobId.isDefined) s\"_JId_${jobId.get}\" else \"\"\n-   val stageIdStr = if (stageId.isDefined) s\"_SId_${stageId.get}\" else \"\"\n-   val stageAttemptIdStr = if (stageAttemptId.isDefined) s\"_${stageAttemptId.get}\" else \"\"\n-   val taskIdStr = if (taskId.isDefined) s\"_TId_${taskId.get}\" else \"\"\n-   val taskAttemptNumberStr =\n-     if (taskAttemptNumber.isDefined) s\"_${taskAttemptNumber.get}\" else \"\"\n-\n-   val context = \"SPARK_\" + from + appIdStr + appAttemptIdStr +\n-     jobIdStr + stageIdStr + stageAttemptIdStr + taskIdStr + taskAttemptNumberStr\n+  from: String,","path":"core/src/main/scala/org/apache/spark/util/Utils.scala","position":32,"original_position":32,"commit_id":"e5252843f41aa25c5a3f15d6324b4ca5a97291b9","original_commit_id":"e5252843f41aa25c5a3f15d6324b4ca5a97291b9","user":{"login":"rxin","id":323388,"avatar_url":"https://avatars.githubusercontent.com/u/323388?v=3","gravatar_id":"","url":"https://api.github.com/users/rxin","html_url":"https://github.com/rxin","followers_url":"https://api.github.com/users/rxin/followers","following_url":"https://api.github.com/users/rxin/following{/other_user}","gists_url":"https://api.github.com/users/rxin/gists{/gist_id}","starred_url":"https://api.github.com/users/rxin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rxin/subscriptions","organizations_url":"https://api.github.com/users/rxin/orgs","repos_url":"https://api.github.com/users/rxin/repos","events_url":"https://api.github.com/users/rxin/events{/privacy}","received_events_url":"https://api.github.com/users/rxin/received_events","type":"User","site_admin":false},"body":"this is off?","created_at":"2016-11-12T06:25:20Z","updated_at":"2016-11-12T06:25:20Z","html_url":"https://github.com/apache/spark/pull/15563#discussion_r87687846","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/15563","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/87687846"},"html":{"href":"https://github.com/apache/spark/pull/15563#discussion_r87687846"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/15563"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/15563","id":90141163,"html_url":"https://github.com/apache/spark/pull/15563","diff_url":"https://github.com/apache/spark/pull/15563.diff","patch_url":"https://github.com/apache/spark/pull/15563.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/15563","number":15563,"state":"closed","locked":false,"title":"[SPARK-16759][CORE] Add a configuration property to pass caller contexts of upstream applications into Spark","user":{"login":"weiqingy","id":8546874,"avatar_url":"https://avatars.githubusercontent.com/u/8546874?v=3","gravatar_id":"","url":"https://api.github.com/users/weiqingy","html_url":"https://github.com/weiqingy","followers_url":"https://api.github.com/users/weiqingy/followers","following_url":"https://api.github.com/users/weiqingy/following{/other_user}","gists_url":"https://api.github.com/users/weiqingy/gists{/gist_id}","starred_url":"https://api.github.com/users/weiqingy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weiqingy/subscriptions","organizations_url":"https://api.github.com/users/weiqingy/orgs","repos_url":"https://api.github.com/users/weiqingy/repos","events_url":"https://api.github.com/users/weiqingy/events{/privacy}","received_events_url":"https://api.github.com/users/weiqingy/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nMany applications take Spark as a computing engine and run on it. This PR adds a configuration property `spark.log.callerContext` that can be used by Spark's upstream applications (e.g. Oozie) to set up their caller contexts into Spark. In the end, Spark will combine its own caller context with the caller contexts of its upstream applications, and write them into Yarn RM log and HDFS audit log.\r\n\r\nThe audit log has a config to truncate the caller contexts passed in (default 128). The caller contexts will be sent over rpc, so it should be concise. The call context written into HDFS log and Yarn log consists of two parts: the information `A` specified by Spark itself and the value `B` of `spark.log.callerContext` property.  Currently `A` typically takes 64 to 74 characters,  so `B` can have up to 50 characters (mentioned in the doc `running-on-yarn.md`)\r\n## How was this patch tested?\r\n\r\nManual tests. I have run some Spark applications with `spark.log.callerContext` configuration in Yarn client/cluster mode, and verified that the caller contexts were written into Yarn RM log and HDFS audit log correctly.\r\n\r\nThe ways to configure `spark.log.callerContext` property:\r\n- In spark-defaults.conf:\r\n\r\n```\r\nspark.log.callerContext  infoSpecifiedByUpstreamApp\r\n```\r\n- In app's source code:\r\n\r\n```\r\nval spark = SparkSession\r\n      .builder\r\n      .appName(\"SparkKMeans\")\r\n      .config(\"spark.log.callerContext\", \"infoSpecifiedByUpstreamApp\")\r\n      .getOrCreate()\r\n```\r\n\r\nWhen running on Spark Yarn cluster mode, the driver is unable to pass 'spark.log.callerContext' to Yarn client and AM since Yarn client and AM have already started before the driver performs `.config(\"spark.log.callerContext\", \"infoSpecifiedByUpstreamApp\")`.\r\n\r\nThe following  example shows the command line used to submit a SparkKMeans application and the corresponding records in Yarn RM log and HDFS audit log.\r\n\r\nCommand:\r\n\r\n```\r\n./bin/spark-submit --verbose --executor-cores 3 --num-executors 1 --master yarn --deploy-mode client --class org.apache.spark.examples.SparkKMeans examples/target/original-spark-examples_2.11-2.1.0-SNAPSHOT.jar hdfs://localhost:9000/lr_big.txt 2 5\r\n```\r\n\r\nYarn RM log:\r\n\r\n<img width=\"1440\" alt=\"screen shot 2016-10-19 at 9 12 03 pm\" src=\"https://cloud.githubusercontent.com/assets/8546874/19547050/7d2f278c-9649-11e6-9df8-8d5ff12609f0.png\">\r\n\r\nHDFS audit log:\r\n\r\n<img width=\"1400\" alt=\"screen shot 2016-10-19 at 10 18 14 pm\" src=\"https://cloud.githubusercontent.com/assets/8546874/19547102/096060ae-964a-11e6-981a-cb28efd5a058.png\">\r\n","created_at":"2016-10-20T06:37:26Z","updated_at":"2016-11-12T06:25:20Z","closed_at":"2016-11-12T02:38:26Z","merged_at":null,"merge_commit_sha":"b3afdd48a7dd71d2a45ee042d89c07099feb4bbb","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/15563/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/15563/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/15563/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/e5252843f41aa25c5a3f15d6324b4ca5a97291b9","head":{"label":"weiqingy:SPARK-16759","ref":"SPARK-16759","sha":"e5252843f41aa25c5a3f15d6324b4ca5a97291b9","user":{"login":"weiqingy","id":8546874,"avatar_url":"https://avatars.githubusercontent.com/u/8546874?v=3","gravatar_id":"","url":"https://api.github.com/users/weiqingy","html_url":"https://github.com/weiqingy","followers_url":"https://api.github.com/users/weiqingy/followers","following_url":"https://api.github.com/users/weiqingy/following{/other_user}","gists_url":"https://api.github.com/users/weiqingy/gists{/gist_id}","starred_url":"https://api.github.com/users/weiqingy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weiqingy/subscriptions","organizations_url":"https://api.github.com/users/weiqingy/orgs","repos_url":"https://api.github.com/users/weiqingy/repos","events_url":"https://api.github.com/users/weiqingy/events{/privacy}","received_events_url":"https://api.github.com/users/weiqingy/received_events","type":"User","site_admin":false},"repo":{"id":65353799,"name":"spark","full_name":"weiqingy/spark","owner":{"login":"weiqingy","id":8546874,"avatar_url":"https://avatars.githubusercontent.com/u/8546874?v=3","gravatar_id":"","url":"https://api.github.com/users/weiqingy","html_url":"https://github.com/weiqingy","followers_url":"https://api.github.com/users/weiqingy/followers","following_url":"https://api.github.com/users/weiqingy/following{/other_user}","gists_url":"https://api.github.com/users/weiqingy/gists{/gist_id}","starred_url":"https://api.github.com/users/weiqingy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weiqingy/subscriptions","organizations_url":"https://api.github.com/users/weiqingy/orgs","repos_url":"https://api.github.com/users/weiqingy/repos","events_url":"https://api.github.com/users/weiqingy/events{/privacy}","received_events_url":"https://api.github.com/users/weiqingy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/weiqingy/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/weiqingy/spark","forks_url":"https://api.github.com/repos/weiqingy/spark/forks","keys_url":"https://api.github.com/repos/weiqingy/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weiqingy/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weiqingy/spark/teams","hooks_url":"https://api.github.com/repos/weiqingy/spark/hooks","issue_events_url":"https://api.github.com/repos/weiqingy/spark/issues/events{/number}","events_url":"https://api.github.com/repos/weiqingy/spark/events","assignees_url":"https://api.github.com/repos/weiqingy/spark/assignees{/user}","branches_url":"https://api.github.com/repos/weiqingy/spark/branches{/branch}","tags_url":"https://api.github.com/repos/weiqingy/spark/tags","blobs_url":"https://api.github.com/repos/weiqingy/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weiqingy/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weiqingy/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/weiqingy/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weiqingy/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/weiqingy/spark/languages","stargazers_url":"https://api.github.com/repos/weiqingy/spark/stargazers","contributors_url":"https://api.github.com/repos/weiqingy/spark/contributors","subscribers_url":"https://api.github.com/repos/weiqingy/spark/subscribers","subscription_url":"https://api.github.com/repos/weiqingy/spark/subscription","commits_url":"https://api.github.com/repos/weiqingy/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/weiqingy/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/weiqingy/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/weiqingy/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/weiqingy/spark/contents/{+path}","compare_url":"https://api.github.com/repos/weiqingy/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weiqingy/spark/merges","archive_url":"https://api.github.com/repos/weiqingy/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weiqingy/spark/downloads","issues_url":"https://api.github.com/repos/weiqingy/spark/issues{/number}","pulls_url":"https://api.github.com/repos/weiqingy/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/weiqingy/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/weiqingy/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weiqingy/spark/labels{/name}","releases_url":"https://api.github.com/repos/weiqingy/spark/releases{/id}","deployments_url":"https://api.github.com/repos/weiqingy/spark/deployments","created_at":"2016-08-10T05:42:57Z","updated_at":"2016-08-10T05:43:20Z","pushed_at":"2016-11-12T00:19:22Z","git_url":"git://github.com/weiqingy/spark.git","ssh_url":"git@github.com:weiqingy/spark.git","clone_url":"https://github.com/weiqingy/spark.git","svn_url":"https://github.com/weiqingy/spark","homepage":null,"size":249611,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"6f3697136aa68dc39d3ce42f43a7af554d2a3bf9","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-11-12T05:41:07Z","pushed_at":"2016-11-12T04:47:57Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":608598,"stargazers_count":10700,"watchers_count":10700,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9992,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":444,"forks":9992,"open_issues":444,"watchers":10700,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/15563"},"html":{"href":"https://github.com/apache/spark/pull/15563"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/15563"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/15563/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/15563/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/15563/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/e5252843f41aa25c5a3f15d6324b4ca5a97291b9"}}}}
{"actor":{"display_login":"rxin"}}