Skip to content

Instantly share code, notes, and snippets.

@allyjweir
Created February 22, 2019 12:21
Show Gist options
  • Save allyjweir/62c5697d3d6eaad930acaa8ac0bcd1dc to your computer and use it in GitHub Desktop.
Save allyjweir/62c5697d3d6eaad930acaa8ac0bcd1dc to your computer and use it in GitHub Desktop.
# This is required before importing `beeline`. This is due to beeline using
# requests (which includes `urllib3`). `urllib3` will import SSL on start up.
# `gevent` will then try to monkey patch a library which has already been
# imported which can lead to unexpected behaviour. On Python 3.6.* specifically
# this can lead to a RecursionError.
#
# By calling `gevent.monkey.patch_all()` before importing `beeline`, gevent can
# safely monkey patch and `beeline` will not fail when trying to send events to
# the API.
#
# See here for more on gevent issue: https://github.com/gevent/gevent/issues/1016
import gevent.monkey
gevent.monkey.patch_all()
import os
import beeline
def post_worker_init(worker):
if os.environ.get('HONEYCOMB_ENABLED', False):
beeline.init(
writekey='<API-KEY-HERE>',
dataset='<DATASET-NAME-HERE>',
service_name='<SERVICE-NAME-HERE>',
debug=True,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment