[SPARK-48209][CORE] Common (java side): Migrate error/warn/info with variables to structured logging framework#46493
[SPARK-48209][CORE] Common (java side): Migrate error/warn/info with variables to structured logging framework#46493panbingkun wants to merge 17 commits intoapache:masterfrom
error/warn/info with variables to structured logging framework#46493Conversation
| try { | ||
| manager.destroy(); | ||
| } catch (InterruptedException ex) { | ||
| logger.info("Interrupted while destroying trust manager: " + ex.toString(), ex); |
There was a problem hiding this comment.
Remove redundant ex.toString().
| listener.getTransferType(), blockIdsToTransfer.length, | ||
| numRetries > 0 ? "(after " + numRetries + " retries)" : ""), e); | ||
|
|
||
| if (numRetries > 0) { |
There was a problem hiding this comment.
Print different log message according to the value of numRetries
| if (time.isDefined) { | ||
| logWarning( | ||
| log"Non-Fatal error during RPC execution: ${MDC(ERROR, lastException)}, " + | ||
| log"retrying (wait=${MDC(WAIT_TIME, time.get.toMillis)} ms, " + |
There was a problem hiding this comment.
Unify WAIT_TIME into RETRY_WAIT_TIME
| import org.apache.spark.{SecurityManager, SparkConf} | ||
| import org.apache.spark.ExecutorDeadException | ||
| import org.apache.spark.internal.config | ||
| import org.apache.spark.internal.{config, LogKeys, MDC} |
There was a problem hiding this comment.
Because NettyBlockTransferService extends BlockTransferService
BlockTransferService is java code, and this change triggered it.
|
|
||
| public class LoggerFactory { | ||
|
|
||
| public static Logger getLogger(String name) { |
| numRemovedBlocks++; | ||
| } else { | ||
| logger.warn("Failed to delete block: " + file.getAbsolutePath()); | ||
| logger.warn("Failed to delete block: {}", |
There was a problem hiding this comment.
I'm not sure it's appropriate to call this LogKeys.PATH$.MODULE$?
| AppExecId id = parseDbAppExecKey(key); | ||
| logger.info("Reloading registered executors: " + id.toString()); | ||
| logger.info("Reloading registered executors: {}", | ||
| MDC.of(LogKeys.APP_EXECUTOR_ID$.MODULE$, id.toString())); |
There was a problem hiding this comment.
Remove redundancy .toString()
| this.reloadCount += 1; | ||
| } catch (Exception ex) { | ||
| logger.warn( | ||
| "Could not load truststore (keep using existing one) : " + ex.toString(), |
There was a problem hiding this comment.
Remove redundancy ex.toString()
| }); | ||
| } catch (Exception e) { | ||
| logger.error("Error while invoking receiveMergeBlockMetaReq() for appId {} shuffleId {} " | ||
| + "reduceId {}", req.appId, req.shuffleId, req.appId, e); |
There was a problem hiding this comment.
fix typo
reduceId {req.appId} -> reduceId {req.reduceId}
| } catch (Exception e) { | ||
| defaultLogger.error("Unable to create an instance of {}", mergeManagerImplClassName); | ||
| defaultLogger.error("Unable to create an instance of {}", | ||
| MDC.of(LogKeys.CLASS_NAME$.MODULE$, mergeManagerImplClassName)); |
There was a problem hiding this comment.
Or call MERGED_SHUFFLE_FILE_MANAGER ?
| logger.info("Updated active local dirs {} and sub dirs {} for application {}", | ||
| Arrays.toString(activeLocalDirs),subDirsPerLocalDir, appId); | ||
| MDC.of(LogKeys.LOCAL_DIRS$.MODULE$, Arrays.toString(activeLocalDirs)), | ||
| MDC.of(LogKeys.NUM_SUB_DIRS$.MODULE$, subDirsPerLocalDir), |
There was a problem hiding this comment.
The subDirsPerLocalDir is actually a number (the number of sub directories), not a sub directory path.
| logger.info("Application {} removed, cleanupLocalDirs = {}", appId, cleanupLocalDirs); | ||
| logger.info("Application {} removed, cleanupLocalDirs = {}", | ||
| MDC.of(LogKeys.APP_ID$.MODULE$, appId), | ||
| MDC.of(LogKeys.LOCAL_DIRS$.MODULE$, cleanupLocalDirs)); |
There was a problem hiding this comment.
cleanupLocalDirs is a boolean. let's just use CLEANUP_LOCAL_DIRS
|
LGTM overall. Thanks for the work! |
Updated, thanks! ❤️ |
| case object LOADED_VERSION extends LogKey | ||
| case object LOAD_FACTOR extends LogKey | ||
| case object LOAD_TIME extends LogKey | ||
| case object LOCAL_DIRS extends LogKey |
There was a problem hiding this comment.
we don't need this anymore
|
Thanks, merging to master |


What changes were proposed in this pull request?
The pr aims to
1.migrate
error/warn/infoin modulecommonwith variables tostructured logging frameworkfor java side.2.convert all dependencies on
org.slf4j.Logger & org.slf4j.LoggerFactorytoorg.apache.spark.internal.Logger & org.apache.spark.internal.LoggerFactory, in order to completelyprohibitimportingorg.slf4j.Logger & org.slf4j.LoggerFactoryin java code later.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?
Was this patch authored or co-authored using generative AI tooling?
No.