Created
April 26, 2019 10:00
-
-
Save Duologic/d58481be1dd1c34d662c5c4aaa6ef45a to your computer and use it in GitHub Desktop.
This initialises Honeycomb.io in a Django/Uwsgi setup (also works with django-admin runserver)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging | |
import beeline | |
from django.core.wsgi import get_wsgi_application | |
def init_beeline(): | |
from django.conf import settings # BEELINE = {'writekey': '', 'dataset': ''} | |
logging.info(f'beeline initialization in process pid {os.getpid()}') | |
beeline.init( | |
writekey=settings.BEELINE['writekey'], | |
dataset=settings.BEELINE['dataset'], | |
service_name='wsgi', | |
debug=settings.DEBUG | |
) | |
try: | |
from uwsgidecorators import postfork | |
except ImportError: | |
# We're not in a uWSGI context, no need to hook Honeycomb.io | |
# initialization to the postfork event. | |
init_beeline() | |
else: | |
@postfork | |
def init_beeline_postfork(): | |
init_beeline() | |
application = get_wsgi_application() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment