-
Notifications
You must be signed in to change notification settings - Fork 46
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
Add default to _after_request_fn #6
Conversation
Hi @gravelg , can you please kindly rebase off master? |
Sure thing, rebased! |
Seems fine with me. Let's see what Carlos thinks. |
Hey @gravelg thanks for the PR - this definitely looks fine (we do the same for the Django instrumentation, for example). But I'm wondering, if the scenario you talk about, is probable another bug (in our side)? If you have a simple test case, I'd love to see it (as to me it sounds you are instrumenting your code and also wrapping some handler of yours through Let me know and I will check ASAP ;) |
Hey @carlosalberto, I don't think I'm doing something out of the ordinary, I just have a global before_request method like this:
This follows the flask docs that say that if a before_request method returns a value, it's interpreted as the return value for the call. This is the case that my PR is trying to fix. |
Hey @gravelg thanks for the reply and sorry for the delayed answer. Nice, I was afraid for a second there was a bug in the actual instrumentation (our side). Would you mind putting a one-line comment (in the code) regarding the situation/condition? After that we can merge it (I'd love to have a note for future maintainers to know in which case we are not having Thanks again for the PR (and the patience)! |
Sure thing, I've added a comment. Let me know if this is what you were looking for. |
Lovely, thanks again for the PR and for the patience! |
If the flask app has a
before_request
method that shortcuts request execution, the request will not be present in the_current_spans
dict but the tracer will still try to finish the span. Adding this default prevents an exception on those calls.