-
Notifications
You must be signed in to change notification settings - Fork 624
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
Provide excluded_urls argument to Flask instrumentation #604
Conversation
The FastAPI instrumentation accepts an 'explicit_urls' argument on initialization. This commit translates that concept to the Flask instrumentation.
|
Co-authored-by: Leighton Chen <lechen@microsoft.com>
@@ -209,6 +217,10 @@ def __init__(self, *args, **kwargs): | |||
) | |||
self._before_request = _before_request | |||
self.before_request(_before_request) |
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.
Does _before_request
and _rewrapped_app
need the excluded_urls
passed in as well?
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.
Good catch.
I need to extend test_automatic.py
to cover this case and then I'll push up the 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.
GitHub didn't update the comment since the change is a few lines up, but this should be taken care of now on line 220 in this commit:
parse_excluded_urls(excluded_urls) | ||
if excluded_urls is not None | ||
else _excluded_urls_from_env | ||
) | ||
app._original_wsgi_app = app.wsgi_app | ||
app.wsgi_app = _rewrapped_app(app.wsgi_app, response_hook) |
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.
app.wsgi_app = _rewrapped_app(app.wsgi_app, response_hook) | |
app.wsgi_app = _rewrapped_app(app.wsgi_app, response_hook, excluded_urls) |
The Flask instrumentation can be applied on two levels: * The `module` level (auto-instrumentation), which patches the `Flask` class. * The `app` level, which patches a `Flask` instance. This commit applies a few missing `excluded_urls` keyword arguments to ensure the auto-instrumentation provides the same configurability as the app-level instrumentation.
Description
Proposal to solve #375 for the
FlaskInstrumentor
, based on theFastAPIInstrumentor
solution in #486.This PR allows users to pass an explicit
excluded_urls
argument during instrumentation.The explicit argument will override values set via environment variable.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
test_programmatic
module was modified to test both environment-based and explicit exclusions.Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.