spark icon indicating copy to clipboard operation
spark copied to clipboard

[SPARK-54314][PYTHON][CONNECT] Improve Server-Side debuggability in Spark Connect by capturing client application's file name and line numbers

Open susheel-aroskar opened this issue 1 month ago • 5 comments

What changes were proposed in this pull request?

Optionally transmitting client-side code location details (function name, file name and line number) along with actions.

Why are the changes needed?

Right now there is no information sent to Spark Connect server that will aid in pointing the location of the call (i.e. Spark data frame action) in the client application code. By making this change, client application call stack details are sent to the server as a list of (function name, file name, line number) tuples where they can be logged in the server logs, included in corresponding open telemetry spans as attributes etc. This will help users looking from server side UI or Console to quickly pinpoint call locations of erring or slow calls in their own (client application) code without server needing to have access to the actual code.

Does this PR introduce any user-facing change?

It includes a new ENV variable SPARK_CONNECT_DEBUG_CLIENT_CALL_STACK which user can set to true / 1 to opt into transmitting client application code locations to server. If opted into, the client app call stack trace details are included in the user_context.extensions field of the Spark Connect protobufs

How was this patch tested?

By adding new unit test test_client_call_stack_trace.py

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

Yes. Some of the unit tests were Generated-by: Cursor

susheel-aroskar avatar Nov 15 '25 00:11 susheel-aroskar

cc @zhengruifeng and @ueshin FYI

HyukjinKwon avatar Nov 18 '25 01:11 HyukjinKwon

This looks neat. If you can rebase it and run the linter that would be awesome. Thanks for working to improve the debugging experience for PySpark connect users :)

Done. Please LMK if anything else is amiss

susheel-aroskar avatar Nov 19 '25 02:11 susheel-aroskar

@susheel-aroskar looks like still some long line issues in the tests.

holdenk avatar Nov 20 '25 18:11 holdenk

Hey @susheel-aroskar can you merge master in and also look at the failing test?

holdenk avatar Nov 27 '25 01:11 holdenk

Hey @susheel-aroskar can you merge master in and also look at the failing test?

Done. Can you PTAL?

sfc-gh-saroskar avatar Dec 04 '25 07:12 sfc-gh-saroskar

gentle ping @zhengruifeng @ueshin @HyukjinKwon

huaxingao avatar Dec 17 '25 04:12 huaxingao

cc @gaogaotiantian

zhengruifeng avatar Dec 17 '25 11:12 zhengruifeng