Skip to content
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

[SPARK-47583][CORE] SQL core: Migrate logError with variables to structured logging framework #45969

Closed
wants to merge 11 commits into from

Conversation

dtenedor
Copy link
Contributor

@dtenedor dtenedor commented Apr 9, 2024

What changes were proposed in this pull request?

Migrate logError with variables of the sql/core module to structured logging framework. This transforms the logError entries of the following API

def logError(msg: => String): Unit

to

def logError(entry: LogEntry): Unit

Why are the changes needed?

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

Does this PR introduce any user-facing change?

Yes, Spark core logs will contain additional MDC

How was this patch tested?

Compiler and scala style checks, as well as code review.

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

No

commit

commit
@github-actions github-actions bot added the SQL label Apr 9, 2024
@dtenedor
Copy link
Contributor Author

dtenedor commented Apr 9, 2024

cc @gengliangwang here is the structured logging migration for logError within sql/core.

@dtenedor dtenedor changed the title [SPARK-47581][CORE] SQL core: Migrate logError with variables to structured logging framework [SPARK-47583][CORE] SQL core: Migrate logError with variables to structured logging framework Apr 23, 2024
Comment on lines 362 to 365
val plans =
sideBySide(currentPhysicalPlan.treeString, newPhysicalPlan.treeString).mkString("\n")
logOnLevel(log"Plan changed:\n" +
log"${MDC(QUERY_PLAN, plans)}")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
val plans =
sideBySide(currentPhysicalPlan.treeString, newPhysicalPlan.treeString).mkString("\n")
logOnLevel(log"Plan changed:\n" +
log"${MDC(QUERY_PLAN, plans)}")
lazy val plans =
sideBySide(currentPhysicalPlan.treeString, newPhysicalPlan.treeString).mkString("\n")
logOnLevel(log"Plan changed:\n${MDC(QUERY_PLAN, plans)}")

@transient private val logOnLevel: ( => MessageWithContext) => Unit =
conf.adaptiveExecutionLogLevel match {
case "TRACE" =>
def fn(log: => LogEntry): Unit = logTrace(log.message)
Copy link
Member

Choose a reason for hiding this comment

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

There is a logTrace accepting MessageWithContext now.

@gengliangwang
Copy link
Member

Thanks, merging to master

JacobZheng0927 pushed a commit to JacobZheng0927/spark that referenced this pull request May 11, 2024
…ctured logging framework

### What changes were proposed in this pull request?

Migrate logError with variables of the sql/core module to structured logging framework. This transforms the logError entries of the following API
```
def logError(msg: => String): Unit
```
to
```
def logError(entry: LogEntry): Unit
```

### Why are the changes needed?

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

### Does this PR introduce _any_ user-facing change?

Yes, Spark core logs will contain additional MDC

### How was this patch tested?

Compiler and scala style checks, as well as code review.

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

No

Closes apache#45969 from dtenedor/log-error-sql-core.

Authored-by: Daniel Tenedorio <daniel.tenedorio@databricks.com>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants