-
Notifications
You must be signed in to change notification settings - Fork 790
flask: fixed http_server_request_duration metrics being recorded for excluded urls #3794
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
base: main
Are you sure you want to change the base?
Conversation
… metrics was being recorded for excluded urls.
duration_attrs_old = otel_wsgi._parse_duration_attrs( | ||
attributes, _StabilityMode.DEFAULT | ||
) | ||
if flask.request and ( |
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.
Maybe we can extract an helper function instead of duplicating the check in _start_response
?
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.
@xrmx Added a helper function that is called here and in _start_response
) | ||
self.assertTrue(number_data_point_seen and histogram_data_point_seen) | ||
self.assertTrue(number_data_point_seen) | ||
self.assertFalse(histogram_data_point_seen) |
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.
Why are those URLs excluded??
excluded_urls is None | ||
or not excluded_urls.url_disabled(flask.request.url) | ||
): | ||
if _should_exclude_request(excluded_urls): |
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 think you'll have to do something like:
+ should_trace = False
def _start_response(status, response_headers, *args, **kwargs):
- if flask.request and (
- excluded_urls is None
- or not excluded_urls.url_disabled(flask.request.url)
- ):
+ nonlocal should_trace
+ should_trace = _should_trace(excluded_urls)
+ if should_trace:
and
+ def _should_trace(excluded_urls) -> bool:
+ return bool(
+ flask.request.url
+ and (excluded_urls is None or not excluded_urls.url_disabled(flask.request.url))
+ )
|
||
### Fixed | ||
|
||
- `opentelemetry-instrumentation-flask`: Fixed http_server_request_duration metrics being recorded for excluded urls. |
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.
- `opentelemetry-instrumentation-flask`: Fixed http_server_request_duration metrics being recorded for excluded urls. | |
- `opentelemetry-instrumentation-flask`: Do not record `http.server.duration` metrics for excluded URLs. |
Fixed an issue #2352 where
http_server_request_duration
metrics was being recorded for excluded urls.Description
Fixes #2352
Type of change
Please delete options that are not relevant.
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
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.