flask: using string keys for wsgi environ values#366
Conversation
Some WSGI servers (such as Gunicorn) expect keys in the environ object to be strings.
codeboten
left a comment
There was a problem hiding this comment.
Thanks for fixing the issue. I guess once the lint check is passing, this is good to go!
| from opentelemetry import trace as trace_api | ||
| from opentelemetry.ext.testutil.wsgitestutil import WsgiTestBase | ||
| from werkzeug.test import Client | ||
| from werkzeug.wrappers import BaseResponse |
There was a problem hiding this comment.
surprised to see these imports order needing to change
There was a problem hiding this comment.
I'm sorting through it, something to do with how isort resolves first party vs third-party imports.
There was a problem hiding this comment.
Try deleting your virtualenv. I had troubles with isort too and it seems that if there is a site-packages/openetelemetry directory (even an empty one), it will think of opentelemetry as a 3rd party. On the other hand, if you install it editable, there is only a opentelemetry.egg-link file, which isort doesn't find, so it falls back to thinking of opentelemetry as a first-party.
EDIT: Or actually, this should not matter since we have opentelemetry as a "known 1st party" in
opentelemetry-python/.isort.cfg
Line 17 in ada53ff
There was a problem hiding this comment.
Okay, I've tracked this down. Effectively modules that are not in the virtualenv are considered first party packages by isort. I'm working on crafting a ticket to fire at isort to clarify this behavior.
For now I'm unblocked by install flask into my virtualenv. On that note, should we be calling out the module that the integration is meant for in the setup.py? I mistakenly thought that flask would be installed when I installed the extension.
| _ENVIRON_STARTTIME_KEY = object() | ||
| _ENVIRON_SPAN_KEY = object() | ||
| _ENVIRON_ACTIVATION_KEY = object() | ||
| _ENVIRON_STARTTIME_KEY = "opentelemetry-flask.starttime_key" |
There was a problem hiding this comment.
| _ENVIRON_STARTTIME_KEY = "opentelemetry-flask.starttime_key" | |
| _ENVIRON_STARTTIME_KEY = "opentelemetry-flask.starttime" |
I think we don't need to add _key to the key.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #366 +/- ##
==========================================
+ Coverage 84.82% 85.13% +0.31%
==========================================
Files 38 38
Lines 1845 1911 +66
Branches 217 225 +8
==========================================
+ Hits 1565 1627 +62
- Misses 214 219 +5
+ Partials 66 65 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@codeboten I've got the build passing, take a look when you can. |
codeboten
left a comment
There was a problem hiding this comment.
Looks good. Thanks for tracking down the isort issue!
Some WSGI servers (such as Gunicorn) expect keys in the environ object
to be strings.
fixes #354.