Add Flask Instrumentation fixes#601
Conversation
7cc2f19 to
d111d44
Compare
|
Reopening up the discussion. |
|
I think it is actually not addressing my comments yet. I exposed an alternative to this here #579 (review). |
Adding @mauriciovasquezbernal comments from past reviews:
|
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
Overall looks good to me.
I have some concerns about the conditionals in the (un)-instrument_app functions. I'll do a more detailed review starting next week.
ext/opentelemetry-ext-flask/src/opentelemetry/ext/flask/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-flask/src/opentelemetry/ext/flask/__init__.py
Outdated
Show resolved
Hide resolved
ext/opentelemetry-ext-flask/src/opentelemetry/ext/flask/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-auto-instrumentation/src/opentelemetry/auto_instrumentation/instrumentor.py
Outdated
Show resolved
Hide resolved
|
Addressed all your comments, @mauriciovasquezbernal, please review again when you have a moment. @lzchen, these changes address your previous concern about doing instrumentation by replacing the Thanks! |
|
This looks good. I'm curious as to whether we can merge the two methods of auto-instrumentation and programmatic instrumentation but still have it patch an |
It is possible but we preferred not to do so. We prefer not to have a method whose actions are different depending on the optional attributes it gets, we rather use |
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
I like the changes in FlaskInstrumentor.
I think the tests could be improved a bit, specially removing code duplication and simplifying the programmatic / automatic tests to avoid checking things that are already covered in other cases.
ext/opentelemetry-ext-flask/src/opentelemetry/ext/flask/__init__.py
Outdated
Show resolved
Hide resolved
|
btw, would you mind moving the entry point definitions to setup.cfg file to keep things uniform with other instrumentations? |
…__.py Co-Authored-By: Mauricio Vásquez <mauricio@kinvolk.io>
Co-Authored-By: Mauricio Vásquez <mauricio@kinvolk.io>
…__.py Co-authored-by: Mauricio Vásquez <mauricio@kinvolk.io>
|
All your comments have been addressed, @mauriciovasquezbernal, thanks for the review! |
mauriciovasquezbernal
left a comment
There was a problem hiding this comment.
Some minor nits. LGTM now, thanks for handling the feedback.
| super().tearDown() | ||
| with self.disable_logging(): | ||
| FlaskInstrumentor().uninstrument_app(self.app) | ||
|
|
There was a problem hiding this comment.
Is it worth to check that calling (un)-instrument twice doesn't cause any issue?
|
|
||
|
|
||
| app = flask.Flask(__name__) | ||
|
|
There was a problem hiding this comment.
Not related to this PR, but is this example missing app.run(), how am I supposed to run it?
| app.wsgi_app = app._original_wsgi_app | ||
|
|
||
| # FIXME add support for other Flask blueprints that are not None | ||
| app.before_request_funcs[None].remove(_before_request) |
There was a problem hiding this comment.
have you considered using the instrumented flag to turn off and on behavior, like the pymongo instrumentation?
Or you could remove by value by comparing the id of the function:
for k, v in before_request_funcs.items():
if v is _before_request:
del before_request_funcs[k]
Although the latter feels more error prone as you are relying on the data structure remaining the same across different versions of flask. The checking of the _is_instrumented value feels more robust here.
toumorokoshi
left a comment
There was a problem hiding this comment.
I think one small edge case around making sure uninstrument is robust, but all looks good otherwise!
toumorokoshi
left a comment
There was a problem hiding this comment.
The issue I raised currently won't affect anyone, since the instrumentation only instruments apps.
…y#601) * chore(plugin-mongodb-core): add missing codecov script * fix(mongodb-plugin): check currentSpan against undefined * chore(scope-managers): return undefined if no scope is found (following open-telemetry#569)
Fixes #599
This is just a separate PR to keep the Flask changes from blocking the instrumentation enhancements.