-
Notifications
You must be signed in to change notification settings - Fork 63
Ignore Missing Entity on Parent Requests #235
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
Ignore Missing Entity on Parent Requests #235
Conversation
…s that have not been populated with an X-Ray Entity.
Here are a few more details as the issue that this pull request addresses is still affecting us. URL Rewrite is a very popular extension to IIS that is provided and supported by Microsoft. One of its core features is to map URLs that are exposed to users to internal URLs. When this happens, the 'parent' request spawns a 'child' request with the mapped URL. This is passed through the complete request and response processing pipeline. The 'parent' request skips most of that and 'waits' for the 'child' request at the end of the pipeline (see the links that I provided above for some more details). The effect is that the parent request does not trigger a call to AWSXRayASPNET.ProcessHTTPRequest but does result in a call to AWSXRayASPNET.ProcessHTTPResponse as can be seen in the stack trace below. There is an implicit assumption in AWSXRayASPNET.ProcessHTTPResponse that a segment was started in a call to AWSXRayRecorderImpl.BeginSegment in AWSXRayASPNET.ProcessHTTPRequest. That is not the case for a 'parent' request and an EntityNotAvailableException is thrown. I think that the only reasonable way to handle this scenario is to bail out of AWSXRayASPNET.ProcessHTTPResponse for the 'parent' request. I.e. Not attempt to add HTTP information to a segment that does not exist because it was never started. @srprash Any thoughts?
|
Hi @samunro |
Hi @srprash, I was able to reproduce this scenario in a new project based on the following Visual Studio 2022 project template. ASP.NET Web Application (.NET Framework) These are the changes that I made. Add this as a child of the configuration element in Web.config. It will rewrite a URL where the path is '/rewrite' to target the root path.
Add this to the MvcApplication class in Global.asax.cs.
To test, I set breakpoints on both BeginRequest and EndRequest above and then browsed to the following URL. https://localhost:44327/rewrite I inspected Request.Url as the breakpoints were hit and this is what I saw. BeginRequest and then EndRequest were hit for the following URL (the 'child request'). Then EndRequest (but not BeginRequest) was hit for the following URL (the 'parent request'). https://localhost:44327/rewrite I hope this shows that assuming in EndRequest that a segment will have been created in BeginRequest is not valid. |
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 @samunro for handling this case. Apologies for delay in reviewing the PR.
Thanks @srprash! Do you have any idea when this will make it through to the NuGet package? |
…s that have not been populated with an X-Ray Entity. (aws#235)
The Rewrite module for example can result in HttpApplication.EndRequest being called multiple times - once for the original (parent) request and once for the child request which has the rewritten URL. The parent request will skip BeginRequest and will not be populated with an X-Ray Entity. It is the child request which is the important one and the parent request will only fail when AddHttpInformation is called anyway. So bail out here in the parent request.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.