Describe the bug
IRoutingFeature cannot be extracted from context features, leading to GetNameFromRouteContext(RouteData) not work (/user/profile/1 cannot be replaced by /user/profile/{id})
To Reproduce
Steps to reproduce the behavior:
app.UseElasticApm(Configuration); in Startup.csRouteDataExpected behavior
Transaction name should be replaced by route data
I'm not sure if it's an AspNetCore bug or elastic apm bug - from doc it should be accessible from 2.1-3.0 but I've tried 2.1, 2.2 and 3.0 and all in 3.0 context.Features doesn't contains IRoutingFeature, but only IRouteValuesFeature, but IRouteValuesFeatures is available after 2.2
Sorry - double checked, seems the issue only happens in AspNetCore 3.0, update info above
Looks more like an AspNetCore bug, created aspnet/AspNetCore#17454
Oh, thanks for reporting. Ok, as it seems we need to adapt this part to 3.0.
Looks like there're some ways to resolve this:
2.1.0 to 2.2.0 - I've made a PR explorering this;TargetFrameworks to target both netstandard2.0 and netcoreapp3.0 and have different dependencies, conditional code blocks to make this function works in AspNetCore 3.0netcoreapp2.1's deprecation - then the first action might become necessaryLooks like there're some ways to resolve this:
- Upgrade dependencies' version from
2.1.0to2.2.0- I've made a PR explorering this;- Use
TargetFrameworksto target bothnetstandard2.0andnetcoreapp3.0and have different dependencies, conditional code blocks to make this function works in AspNetCore 3.0- Wait for
netcoreapp2.1's deprecation - then the first action might become necessary
Thanks @yhvicey
Point 2 sounds like a very good idea! We already have an issue for adding 3.0: https://github.com/elastic/apm-agent-dotnet/issues/546
To point 1 I added a comment in the PR - that would bee too radical at this point, since 2.1 is LTS supported.
To point 3: Given that 2.1 is LTS, it'll be supported for a long time.
So, overall I think netcoreapp3.0 target could help us here.
This is the root cause of #541 so that can probably be closed if you don't want two of the same issue being tracked.
Rather than looking in the context.Features dictionary directly, context.GetRouteData() does work across versions as far as I've tested.
Rather than looking in the context.Features dictionary directly, context.GetRouteData() does work across versions as far as I've tested.
@cbo100, thanks for your input. I changed the logic for getting route data to GetRouteData() extension method.
@gregkalapos, I believe it can be closed due to #647 was merged
@gregkalapos, I believe it can be closed due to #647 was merged
Correct, the fix was part of #647. Thanks!
Is there any ETA for new version of APM agent, which fixes this issue?