apm-agent-dotnet icon indicating copy to clipboard operation
apm-agent-dotnet copied to clipboard

Transaction name wrongly assigned NET461

Open fabiobernalt opened this issue 2 years ago • 0 comments

The transaction name in NET461 is wrongly assigned when there are two methods sharing a similar route. When the transaction name is set due to the hierarchy of the routes, it always takes the first one when calling the second endpoint.

Package: Elastic.Apm.AspNetFullFramework Class: ElasticApmModule Method: ProcessEndRequest

Steps to reproduce:

  1. Clone repo
  2. Replace the sample class AttributeRoutingWebApiController in sample/AspNetFullFrameworkSampleApp
  3. Set the LogLevel to Debug
  4. Run project and call endpoint route1/{route1:guid}/routes/process
  5. Check the transaction name is route1/{route1:guid}/routes/{route2} instead of the one requested
namespace AspNetFullFrameworkSampleApp.Controllers
{
	[RoutePrefix(RoutePrefix)]
	public class AttributeRoutingWebApiController : ApiController
	{
		public const string RoutePrefix = "route1/{route1:guid}/routes";
		public const string Route = "process";

		[HttpGet]
		[Route("{route2}")]
		public IHttpActionResult Get1([FromUri] Guid route1, Guid route2) =>
			Ok($"attributed routed web api controller {route1} and {route2}");

		[HttpGet]
		[Route(Route)]
		public IHttpActionResult Get2([FromUri] Guid route1) =>
			Ok($"attributed routed web api controller {route1}");
	}
}

fabiobernalt avatar Mar 07 '22 20:03 fabiobernalt