Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add __enhanced_stack_trace query to workers #537

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

Merged
merged 20 commits into from
Jun 18, 2024
Merged

Add __enhanced_stack_trace query to workers #537

merged 20 commits into from
Jun 18, 2024

Conversation

twin-drill
Copy link
Contributor

What was changed

Added a new query, __enhanced_stack_trace, to workers. This query builds upon the pre-existing __stack_trace query to provide mappings of code where each worker is currently suspended/working.

Added integration test: test_workflow_enhanced_stack_trace, with similar tests to those in test_workflow_stack_trace; adjusted test_workflow_signal_and_query_errors to account for new default queries in workers.

How was this tested:

Integration tests were run, locally passing (using Temporalite and Temporal dev server)

@CLAassistant
Copy link

CLAassistant commented May 31, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Divyank Jain seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

added query to workflow internals, created integration test and modified query error integration test to account for new default query.
@twin-drill
Copy link
Contributor Author

Will get to adding an external test for test_workflow_enhanced_stack_trace and then reformatting on Monday!

@twin-drill twin-drill marked this pull request as ready for review June 3, 2024 18:23
@twin-drill twin-drill requested a review from a team as a code owner June 3, 2024 18:23
@twin-drill twin-drill assigned twin-drill and unassigned twin-drill Jun 3, 2024
Comment on lines 2162 to 2164
for source in trace["sources"].keys():
if source.endswith("externalstacktrace.py 53"):
fn = source
Copy link
Member

Choose a reason for hiding this comment

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

So the thing I was kind of interested to see work is that a workflow defined in one file loading code from another file would properly show both files in the sources.

So, I don't know if you need to copy the whole workflow to the externalstacktrace file, but rather just run a coroutine that imports some code from it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gotcha, I'll probably create another file to avoid a circular dependency for it then.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Looks great!

@@ -1791,6 +1800,42 @@ def _stack_trace(self) -> str:
)
return "\n\n".join(stacks)

def _enhanced_stack_trace(self) -> temporalio.common._EnhancedStackTrace:
Copy link
Member

@cretz cretz Jun 3, 2024

Choose a reason for hiding this comment

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

Can you give an idea of what this full string looks like for a simple workflow (or what it looks like in the test cases)/ My concern is that Python stack traces are pretty poor and so we'd be showing a lot of source lines for our code instead of user code.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, even just showing us what this may look like here in GH comments can help us understand how good/bad the Python stack traces may be. I recall they are pretty bad for many users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

stack_trace.txt
This is the test output for a __stack_trace call, for reference!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! Yeah that does a good job of showing the current poor state of Python stack traces. We'll confer as a team to see what we can do here (and if we want enhanced to wait on that).

@twin-drill
Copy link
Contributor Author

Writing down for myself -- ensure that FileSlice.content is newline-terminated

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

Approving with the understanding that the stack traces in Python in general need improvement

twin-drill and others added 5 commits June 12, 2024 16:48
…nal_enhanced_stack_trace` to work with redefinitions, will try to mark `test_workflow_external_multifile_enhanced_stack_trace` as a test to skip until we find a way to deterministically get those results. (I really have to rename these tests)
@cretz
Copy link
Member

cretz commented Jun 17, 2024

@twin-drill - CI is failing for a known issue after CLI release. I will make a PR soon to fix it.

… set to 0. Update tests to account for this, made them more specific while I was at it.
Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Looking good!

@cretz cretz merged commit 4f646c2 into temporalio:main Jun 18, 2024
12 checks passed
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.

4 participants