-
Notifications
You must be signed in to change notification settings - Fork 649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flask: using string keys for wsgi environ values #366
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surprised to see these imports order needing to change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
known_first_party=opentelemetry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference: PyCQA/isort#1104
_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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after lint too.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@codeboten I've got the build passing, take a look when you can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.