Apm-agent-dotnet: [AspNetCore 3.0] 'IRoutingFeature' cannot be extracted from context features

Created on 27 Nov 2019  路  11Comments  路  Source: elastic/apm-agent-dotnet

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:

  1. Create AspNet Core 3.0 project from template
  2. Add Elastic.Apm.AspNetCore package reference
  3. Add app.UseElasticApm(Configuration); in Startup.cs
  4. You'll see transaction name won't be replaced by RouteData

Expected behavior
Transaction name should be replaced by route data

bug

All 11 comments

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:

  1. Upgrade dependencies' version from 2.1.0 to 2.2.0 - I've made a PR explorering this;
  2. Use TargetFrameworks to target both netstandard2.0 and netcoreapp3.0 and have different dependencies, conditional code blocks to make this function works in AspNetCore 3.0
  3. Wait for netcoreapp2.1's deprecation - then the first action might become necessary

Looks like there're some ways to resolve this:

  1. Upgrade dependencies' version from 2.1.0 to 2.2.0 - I've made a PR explorering this;
  2. Use TargetFrameworks to target both netstandard2.0 and netcoreapp3.0 and have different dependencies, conditional code blocks to make this function works in AspNetCore 3.0
  3. 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?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fredeil picture fredeil  路  3Comments

mterwoord picture mterwoord  路  7Comments

bliles picture bliles  路  7Comments

lreuven picture lreuven  路  6Comments

vhatsura picture vhatsura  路  4Comments