Skip to content

Commit

Permalink
Attach sentry monitor to actor, not scheduler
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Apr 30, 2023
1 parent 9c385e1 commit 0054488
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions dramatiq_crontab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def cron_test():
The monitors timezone should be set to Europe/Berlin.
"""

def decorator(func):
def decorator(actor):
*_, day_of_week = schedule.split(" ")

if day_of_week.lower() not in (
Expand All @@ -60,20 +60,19 @@ def decorator(func):
"Please use a literal day of week (Mon, Tue, Wed, Thu, Fri, Sat, Sun) or *"
)

fn = getattr(func, "send")
if monitor is not None:
fn = monitor(func.actor_name)(fn)
actor.fn = monitor(actor.actor_name)(actor.fn)

scheduler.add_job(
fn,
actor.send,
CronTrigger.from_crontab(
schedule,
timezone=timezone.get_default_timezone(),
),
name=func.actor_name,
name=actor.actor_name,
)
# We don't add the Sentry monitor on the actor itself, because we only want to
# monitor the cron job, not the actor itself, or it's direct invocations.
return func
return actor

return decorator

0 comments on commit 0054488

Please sign in to comment.