-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-48320][CORE][DOCS] Add structured logging guide to the scala and java doc #46634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a9ff819
[SPARK-48320][CORE][DOCS] Add external third-party ecosystem access g…
panbingkun 541ccbc
update
panbingkun f67d100
Merge branch 'master' into SPARK-48320
panbingkun 1c766c5
fix
panbingkun 173acdd
Merge branch 'master' into SPARK-48320
panbingkun ccba177
Merge branch 'master' into SPARK-48320
panbingkun 90309db
remove README.md
panbingkun 7a96541
update
panbingkun ebfe862
Apply suggestions from code review
panbingkun a8cf34a
update
panbingkun f2ac58f
Merge branch 'master' into SPARK-48320
panbingkun d51a253
update
panbingkun 4572dcd
Merge branch 'master' into SPARK-48320
panbingkun a5fcf8f
restore README.md
panbingkun d7969d5
Merge branch 'master' into SPARK-48320
panbingkun a7180df
Revert "restore README.md"
panbingkun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
common/utils/src/main/scala/org/apache/spark/internal/README.md
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,9 +26,10 @@ | |
| import org.apache.logging.log4j.Level; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import org.apache.spark.internal.SparkLogger; | ||
| import org.apache.spark.internal.LogKey; | ||
| import org.apache.spark.internal.LogKeys; | ||
| import org.apache.spark.internal.MDC; | ||
| import org.apache.spark.internal.SparkLogger; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
|
|
@@ -68,8 +69,11 @@ private String basicMsg() { | |
|
|
||
| private final MDC executorIDMDCValueIsNull = MDC.of(LogKeys.EXECUTOR_ID$.MODULE$, null); | ||
|
|
||
| private final MDC externalSystemCustomLog = | ||
| MDC.of(CustomLogKeys.CUSTOM_LOG_KEY$.MODULE$, "External system custom log message."); | ||
| private final MDC scalaCustomLogMDC = | ||
| MDC.of(CustomLogKeys.CUSTOM_LOG_KEY$.MODULE$, "Scala custom log message."); | ||
|
|
||
| private final MDC javaCustomLogMDC = | ||
| MDC.of(JavaCustomLogKeys.CUSTOM_LOG_KEY, "Java custom log message."); | ||
|
|
||
| // test for basic message (without any mdc) | ||
| abstract String expectedPatternForBasicMsg(Level level); | ||
|
|
@@ -89,8 +93,11 @@ private String basicMsg() { | |
| // test for message (with mdc - the value is null) | ||
| abstract String expectedPatternForMsgWithMDCValueIsNull(Level level); | ||
|
|
||
| // test for external system custom LogKey | ||
| abstract String expectedPatternForExternalSystemCustomLogKey(Level level); | ||
| // test for scala custom LogKey | ||
| abstract String expectedPatternForScalaCustomLogKey(Level level); | ||
|
|
||
| // test for java custom LogKey | ||
| abstract String expectedPatternForJavaCustomLogKey(Level level); | ||
|
|
||
| @Test | ||
| public void testBasicMsgLogger() { | ||
|
|
@@ -142,8 +149,6 @@ public void testLoggerWithMDC() { | |
| Runnable errorFn = () -> logger().error(msgWithMDC, executorIDMDC); | ||
| Runnable warnFn = () -> logger().warn(msgWithMDC, executorIDMDC); | ||
| Runnable infoFn = () -> logger().info(msgWithMDC, executorIDMDC); | ||
| Runnable debugFn = () -> logger().debug(msgWithMDC, executorIDMDC); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After #46405, the following 2 lines of code are no longer needed. |
||
| Runnable traceFn = () -> logger().trace(msgWithMDC, executorIDMDC); | ||
| List.of( | ||
| Pair.of(Level.ERROR, errorFn), | ||
| Pair.of(Level.WARN, warnFn), | ||
|
|
@@ -213,20 +218,46 @@ public void testLoggerWithMDCValueIsNull() { | |
| } | ||
|
|
||
| @Test | ||
| public void testLoggerWithExternalSystemCustomLogKey() { | ||
| Runnable errorFn = () -> logger().error("{}", externalSystemCustomLog); | ||
| Runnable warnFn = () -> logger().warn("{}", externalSystemCustomLog); | ||
| Runnable infoFn = () -> logger().info("{}", externalSystemCustomLog); | ||
| public void testLoggerWithScalaCustomLogKey() { | ||
| Runnable errorFn = () -> logger().error("{}", scalaCustomLogMDC); | ||
| Runnable warnFn = () -> logger().warn("{}", scalaCustomLogMDC); | ||
| Runnable infoFn = () -> logger().info("{}", scalaCustomLogMDC); | ||
| List.of( | ||
| Pair.of(Level.ERROR, errorFn), | ||
| Pair.of(Level.WARN, warnFn), | ||
| Pair.of(Level.INFO, infoFn)).forEach(pair -> { | ||
| try { | ||
| assertTrue(captureLogOutput(pair.getRight()).matches( | ||
| expectedPatternForScalaCustomLogKey(pair.getLeft()))); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLoggerWithJavaCustomLogKey() { | ||
| Runnable errorFn = () -> logger().error("{}", javaCustomLogMDC); | ||
| Runnable warnFn = () -> logger().warn("{}", javaCustomLogMDC); | ||
| Runnable infoFn = () -> logger().info("{}", javaCustomLogMDC); | ||
| List.of( | ||
| Pair.of(Level.ERROR, errorFn), | ||
| Pair.of(Level.WARN, warnFn), | ||
| Pair.of(Level.INFO, infoFn)).forEach(pair -> { | ||
| try { | ||
| assertTrue(captureLogOutput(pair.getRight()).matches( | ||
| expectedPatternForExternalSystemCustomLogKey(pair.getLeft()))); | ||
| expectedPatternForJavaCustomLogKey(pair.getLeft()))); | ||
| } catch (IOException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| class JavaCustomLogKeys { | ||
| // Custom `LogKey` must be `implements LogKey` | ||
| public static class CUSTOM_LOG_KEY implements LogKey { } | ||
|
|
||
| // Singleton | ||
| public static final CUSTOM_LOG_KEY CUSTOM_LOG_KEY = new CUSTOM_LOG_KEY(); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mridulm @panbingkun This README is for Spark developers. As long as it doesn't mention 3rd party supports, can we just keep it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine to it, WDYT @mridulm ?
we can just put the new description in the
scala/javadoc.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will wait for @mridulm's response until this weekend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC @panbingkun included the contents into the existing code; which is also a nice addition to the code documentation.
IMO that is a better overall approach given this is internal to spark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I have adopted the plan of deleting
README.md