Skip to content

Instantly share code, notes, and snippets.

@Duologic
Created April 26, 2019 10:00
Show Gist options
  • Save Duologic/d58481be1dd1c34d662c5c4aaa6ef45a to your computer and use it in GitHub Desktop.
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)
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