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

Improve error handling and helpers for failed tasks #415

Conversation

ybastide
Copy link
Contributor

@ybastide ybastide commented Jul 12, 2023

Implement #416.

@virtualtam would this match what you want? What's missing?

@ybastide ybastide added the WIP label Jul 12, 2023
@ybastide ybastide requested a review from virtualtam July 12, 2023 18:23
@ybastide ybastide force-pushed the improvement/DATA-16022/Simpleflow-Improve-error-handling-and-helpers-for-failed-tasks branch 2 times, most recently from bb14952 to 8da51c5 Compare July 12, 2023 18:46
ybastide added 6 commits July 12, 2023 21:11
* create task_error, task_error_type on init
* add reason, details

Signed-off-by: Yves Bastide <[email protected]>
@ybastide ybastide force-pushed the improvement/DATA-16022/Simpleflow-Improve-error-handling-and-helpers-for-failed-tasks branch from 8da51c5 to 9fff72d Compare July 12, 2023 19:16
@ybastide ybastide marked this pull request as ready for review July 12, 2023 19:30
Copy link
Contributor

@ewjoachim ewjoachim left a comment

Choose a reason for hiding this comment

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

Not sure what this PR is about ?

logger.info(
"spawning new activity id=%s worker pid=%d heartbeat=%s",
task.activity_id,
os.getpid(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe displaying the pid should be the role of the log formatter, not the log message itself. https://docs.python.org/3/library/logging.html#logrecord-attributes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... and it is. Good catch!

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how to handle this though, as we integrate Simpleflow in a Django project, and inherit from the logger configured in the project's settings 🤔

Copy link
Contributor Author

@ybastide ybastide Jul 13, 2023

Choose a reason for hiding this comment

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

Maybe add "formatter": "simpleflow_formatter", to the Django project's settings? What could go wrong? 🙃
EDIT: simpleflow does use its logger, so the pid is present

Copy link
Contributor

Choose a reason for hiding this comment

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

Double-checked:

What I'm not clear on though, is whether we use:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, it's confusing...

simpleflow worker.start -N1 --task-list example
2023-07-18T16:11:48 INFO [process=MainProcess, pid=34924]: starting <bound method Poller.start of ActivityPoller(domain=TestDomain, task_list=example)>

Same on Papertrail

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks Logged To Me 👍

ybastide added 2 commits July 13, 2023 12:08
Already present in the default log formatter.

Signed-off-by: Yves Bastide <[email protected]>
I'm not sure how to do it cleanly, so...

Signed-off-by: Yves Bastide <[email protected]>
@ybastide
Copy link
Contributor Author

Not sure what this PR is about ?

right, I'll fill the descrition 🙂

@ybastide ybastide changed the title 🧇 Improve error handling and helpers for failed tasks Jul 13, 2023
ybastide added 2 commits July 13, 2023 14:45
Signed-off-by: Yves Bastide <[email protected]>
This should not be necessary anymore...

Signed-off-by: Yves Bastide <[email protected]>
@virtualtam
Copy link
Contributor

Also, 🧇 !

@ybastide ybastide merged commit 67a614c into main Jul 19, 2023
@ybastide ybastide deleted the improvement/DATA-16022/Simpleflow-Improve-error-handling-and-helpers-for-failed-tasks branch July 19, 2023 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants