Skip to content

[SPARK-47575][INFRA] Implement logWarning API in structured logging framework#45770

Closed
gengliangwang wants to merge 1 commit into
apache:masterfrom
gengliangwang:logWarning
Closed

[SPARK-47575][INFRA] Implement logWarning API in structured logging framework#45770
gengliangwang wants to merge 1 commit into
apache:masterfrom
gengliangwang:logWarning

Conversation

@gengliangwang
Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Implement logWarning API in structured logging framework. Also, refactor the logging test suites to reduce duplicated code.

Why are the changes needed?

To enhance Apache Spark's logging system by implementing structured logging.

Does this PR introduce any user-facing change?

No

How was this patch tested?

New unit tests

Was this patch authored or co-authored using generative AI tooling?

No

Copy link
Copy Markdown
Member

@ueshin ueshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@gengliangwang
Copy link
Copy Markdown
Member Author

@ueshin Thanks for the review.
Merging to master


def msgWithMDC: LogEntry = log"Lost executor ${MDC(EXECUTOR_ID, "1")}."

def msgWithMDCAndException: LogEntry = log"Error in executor ${MDC(EXECUTOR_ID, "1")}."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I'm a little confused by this, it has basically just text in it like msgWithMDC so where is the "AndException" part?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When logging with an exception, the output will contain the field "exception".

{"ts":"2024-04-01T09:43:18.892-0700","level":"ERROR","msg":"Error in executor 1.","context":{"executor_id":"1"},"exception":{"class":"java.lang.RuntimeException","msg":"OOM","stacktrace":"..."},"logger":"org.apache.spark.util.StructuredLoggingSuite"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok but the function itself doesn't have an exception in it, this just seems to be another string with MDC which is just different text then msgWithMDC looking at where you use it I see the message copied into expectedPatternForMsgWithMDCAndException and then this passed into "Logging with MDC and Exception"... why isn't this just called msgWithMDC2 since this function itself doesn't take an exception or add any functionality related to an exception

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can make it msgWithMDC2, or reuse msgWithMDC and remove msgWithMDCAndException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants