Koed00 / django-q

A multiprocessing distributed task queue for Django
https://django-q.readthedocs.org
MIT License
1.83k stars 285 forks source link

error_reporter , how to build my custom error reporter ? #708

Open danielb-magnadint opened 1 year ago

danielb-magnadint commented 1 year ago

I want to build my custom error reporter but I cant get it to read it from the configuration. Also found out that sentry and rollbar have entry points inside django_q so maybe its not possible to do my own custom implementation ?

I see that in the code it uses pkg_resources.iter_entry_points( "djangoq.errorreporters", name )

so somehow I need to register a entry point.

Any suggestions are welcome. Thanks

amirraouf commented 1 year ago

I have a tweak

def load_slack_entry_point_for_django_q():
    ep = pkg_resources.EntryPoint.parse('key = pkg_name:ReporterClass')
    d = pkg_resources.Distribution(location="pkg_name", project_name="pkg_name", version="<ver_number>")
    d._ep_map = {'djangoq.errorreporters': {'key': ep}}
    fixed = True
    while fixed:
        try:
            pkg_resources.working_set.add(d, 'slack')
            fixed = False
        except TypeError:
            continue

at manage.py or any file run at the runtime of the project

if __name__ == "__main__":
    load_slack_entry_point_for_django_q()
    main()

then create a package similar to django-q-sentry, add the reporter class you want to add