<p dir="auto">This is what I had to do to get Raven's Sentry client working with Celery:</p>
<p dir="auto">Disable the logger to avoid duplicates in Sentry (one would be logged in <code class="notranslate">celery.worker.job</code> with no frames locals, the other one with the root logger with locals).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    celery.worker.job:
      level: INFO
      handlers: [yourhandler]
      propagate: no"><pre class="notranslate"><code class="notranslate">    celery.worker.job:
      level: INFO
      handlers: [yourhandler]
      propagate: no
</code></pre></div>
<p dir="auto">I also had <code class="notranslate">CELERYD_HIJACK_ROOT_LOGGER</code> to <code class="notranslate">False</code> in my Celery <a href="http://docs.celeryproject.org/en/latest/configuration.html#celeryd-hijack-root-logger" rel="nofollow">configuration</a>, and had to disable celery logging completely:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="@signals.setup_logging.connect
def setup_logging(**kwargs):
    &quot;&quot;&quot;Setup logging.&quot;&quot;&quot;     
    pass"><pre class="notranslate"><span class="pl-en">@<span class="pl-s1">signals</span>.<span class="pl-s1">setup_logging</span>.<span class="pl-s1">connect</span></span>
<span class="pl-k">def</span> <span class="pl-en">setup_logging</span>(<span class="pl-c1">**</span><span class="pl-s1">kwargs</span>):
    <span class="pl-s">"""Setup logging."""</span>     
    <span class="pl-k">pass</span></pre></div>
<p dir="auto">I set up Sentry exactly like in the <a href="http://raven.readthedocs.org/en/latest/integrations/celery.html" rel="nofollow">docs</a>:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from raven import Client
from raven.contrib.celery import register_signal, register_logger_signal

client = Client()

# register a custom filter to filter out duplicate logs
register_logger_signal(client)

# hook into the Celery error handler
register_signal(client)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">raven</span> <span class="pl-k">import</span> <span class="pl-v">Client</span>
<span class="pl-k">from</span> <span class="pl-s1">raven</span>.<span class="pl-s1">contrib</span>.<span class="pl-s1">celery</span> <span class="pl-k">import</span> <span class="pl-s1">register_signal</span>, <span class="pl-s1">register_logger_signal</span>

<span class="pl-s1">client</span> <span class="pl-c1">=</span> <span class="pl-v">Client</span>()

<span class="pl-c"># register a custom filter to filter out duplicate logs</span>
<span class="pl-en">register_logger_signal</span>(<span class="pl-s1">client</span>)

<span class="pl-c"># hook into the Celery error handler</span>
<span class="pl-en">register_signal</span>(<span class="pl-s1">client</span>)</pre></div>
<p dir="auto">I use:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="celery==3.1.17
kombu==3.0.24
raven==5.1.1"><pre class="notranslate"><code class="notranslate">celery==3.1.17
kombu==3.0.24
raven==5.1.1
</code></pre></div>
<p dir="auto">I understand there was already some discussion about this in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="27362729" data-permission-text="Title is private" data-url="https://github.com/celery/celery/issues/1867" data-hovercard-type="issue" data-hovercard-url="/celery/celery/issues/1867/hovercard" href="https://github.com/celery/celery/issues/1867">#1867</a>, not sure if it has evolved.</p>
<h1 dir="auto">Checklist</h1>

<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+label%3A%22Category%3A+Documentation%22+">issues list</a><br>
for similar or identical bug reports.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/pulls?q=is%3Apr+label%3A%22Category%3A+Documentation%22">pull requests list</a><br>
for existing proposed fixes.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have checked the <a href="https://github.com/celery/celery/commits/master">commit log</a><br>
to find out if the bug was already fixed in the master branch.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I have included all related issues and possible duplicate issues in this issue<br>
(If there are none, check this box anyway).</li>
</ul>
<h2 dir="auto">Related Issues and Possible Duplicates</h2>

<h4 dir="auto">Related Issues</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h4 dir="auto">Possible Duplicates</h4>
<ul dir="auto">
<li>None</li>
</ul>
<h1 dir="auto">Description</h1>

<p dir="auto">My Django application has lots of periodic tasks defined in different applications.<br>
In the previous version of Celery (v4.x), I used to define the periodic task like</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from celery.task import periodic_task

@periodic_task(name='authentication.periodic_task.clear_refresh_token', run_every=timedelta(days=1))
def clear_refresh_token():
    pass"><pre class="notranslate"><code class="notranslate">from celery.task import periodic_task

@periodic_task(name='authentication.periodic_task.clear_refresh_token', run_every=timedelta(days=1))
def clear_refresh_token():
    pass
</code></pre></div>
<p dir="auto">After the removal of the <code class="notranslate">periodic_task</code> decorator from v5.x, it is unclear how to define the auto-discoverable periodic tasks.</p>
<p dir="auto">From the period task documentation <a href="https://docs.celeryproject.org/en/4.4.0/userguide/periodic-tasks.html#entries" rel="nofollow">https://docs.celeryproject.org/en/4.4.0/userguide/periodic-tasks.html#entries</a>, It requires the <code class="notranslate">app</code> module to define the signal under which the periodic tasks has to be registered.</p>
<p dir="auto">This is fine when the periodic tasks are defined in the root module (main application module), but what for the other module?</p>
<p dir="auto">Also previously, it was easy to define the periodic tasks by using the decorator, and thus have the flexibility to define periodic tasks to any method, as per the new update, do I need to create separated <code class="notranslate">shared_task</code> first and then register them as a periodic task under the signal receiver?</p>
<h1 dir="auto">Suggestions</h1>