Skip to content

Commit

Permalink
Merge pull request #23 from honeycombio/nathanleclaire.use_dict_get
Browse files Browse the repository at this point in the history
Use dict get instead of direct dict access in Flask init
  • Loading branch information
nathanleclaire authored Sep 19, 2018
2 parents 043d138 + 7a29757 commit dc0e83f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions beeline/middleware/flask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ def __init__(self, app):
self.app = app

def __call__(self, environ, start_response):
trace_name = "flask_http_%s" % environ['REQUEST_METHOD'].lower()
trace_name = "flask_http_%s" % environ.get('REQUEST_METHOD', None)
if trace_name is not None:
trace_name = trace_name.lower()
beeline._new_event(data={
"type": "http_server",
"request.host": environ['HTTP_HOST'],
"request.method": environ['REQUEST_METHOD'],
"request.path": environ['PATH_INFO'],
"request.remote_addr": environ['REMOTE_ADDR'],
"request.host": environ.get('HTTP_HOST', None),
"request.method": environ.get('REQUEST_METHOD', None),
"request.path": environ.get('PATH_INFO', None),
"request.remote_addr": environ.get('REMOTE_ADDR', None),
"request.content_length": environ.get('CONTENT_LENGTH', 0),
"request.user_agent": environ['HTTP_USER_AGENT'],
"request.scheme": environ['wsgi.url_scheme'],
"request.query": environ['QUERY_STRING']
"request.user_agent": environ.get('HTTP_USER_AGENT', None),
"request.scheme": environ.get('wsgi.url_scheme', None),
"request.query": environ.get('QUERY_STRING', None)
}, trace_name=trace_name, top_level=True)

def _start_response(status, headers, *args):
Expand Down
2 changes: 1 addition & 1 deletion beeline/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.3.0'
VERSION = '1.3.1'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup(
python_requires='>=2.7',
name='honeycomb-beeline',
version='1.3.0',
version='1.3.1',
description='Honeycomb library for easy instrumentation',
url='https://github.com/honeycombio/beeline-python',
author='Honeycomb.io',
Expand Down

0 comments on commit dc0e83f

Please sign in to comment.