Description of changes:
Fixed the route parsing logic by storing a weak reference of the httpContext to be accessed later by processors. Weak References allow the garbage collectorto reclaim memory if the object is no longer used.
We are storing references due to the following:
When a request is received, an activity starts immediately and in that phase, the routing middleware hasn't executed and thus the routing data isn't available yet
Once the routing middleware is executed, and the request is matched to the route template, we are certain the routing data is avaialble when any children activities are started.
We then use this HttpContext object to access the now available route data.
In AwsSpanProcessingUtil, we extract the HttpContext object and attempt to get the route data. If it's not available, we fallback to the original logic to compute using the path. This is the case when a request is made that doesn't match to any route pattern.
Testing:
Added unit tests for the extra if condition.
Also tested by running a sample app with a new route /outgoing/test/{id} and making a call to /outgoing/test/2 and these are the resulting activities (pay special attention to aws.local.operation since that's the whole point of the fix):
Description of changes: Fixed the route parsing logic by storing a weak reference of the httpContext to be accessed later by processors. Weak References allow the garbage collectorto reclaim memory if the object is no longer used. We are storing references due to the following:
Testing: Added unit tests for the extra if condition.
Also tested by running a sample app with a new route /outgoing/test/{id} and making a call to /outgoing/test/2 and these are the resulting activities (pay special attention to aws.local.operation since that's the whole point of the fix):
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.