https://prefect.io logo
b

bral

10/22/2020, 3:29 AM
Hi folks! Has anyone had any experience using Sentry with the Prefect?
👀 1
r

Raphaël Riel

10/22/2020, 12:00 PM
I’ve made a brief attempt at it, but with no success. I think the fact that every task run in its own isolated environment may be my problem. I plan on putting more time on this problem soon, my plan being to : A) Initialize Sentry on all tasks with a Context manager and/or decorator. and/or B) Find a way to have Sentry listens to Prefect’s Logs (But with this method I would lose all of the Stacktrace and local vars details)
I would be interested to see how one would add such “always-on” listener/try-except on flow+task code while in the context of an execution on the agent.
d

Dylan

10/22/2020, 1:27 PM
Hey @bral! I’m not familiar specifically with Sentry, but you might find the following concepts helpful if you’d like to explore an integration: https://docs.prefect.io/core/concepts/logging.html#extra-loggers https://docs.prefect.io/core/concepts/notifications.html#state-handlers
You can 1) send logs to sentry with a custom logger 2) send state updates with a state handler
If you need to do some sentry-specific setup for each Task, you might also consider subclassing
Task
and configuring the setup in the subclass’s
init
method
r

Raphaël Riel

10/22/2020, 1:51 PM
Oh! I really like the idea of Subclassing
Task
to add all of my custom code! Thanks @Dylan!
d

Dylan

10/22/2020, 1:53 PM
Anytime!
b

bral

10/22/2020, 3:49 PM
@Dylan Thanks for response!
👍 1