Hi folks! Has anyone had any experience using <Sen...
# ask-community
b
Hi folks! Has anyone had any experience using Sentry with the Prefect?
đź‘€ 1
r
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
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
Oh! I really like the idea of Subclassing
Task
to add all of my custom code! Thanks @Dylan!
d
Anytime!
b
@Dylan Thanks for response!
👍 1