Problem
If the .NET agent is monitoring an Asp.Net Core “Minimal APIs” application, multiple endpoints may appear as a single web transaction. This is because the endpoints share the same route path even if they have different HTTP request methods.
To differentiate these endpoints, we recommend applying the SetTransactionName()
API call.
Solution
Add SetTransactionName()
to give each endpoint a unique transaction name. While your arguments for the API call may vary, we recommend adding SetTransactionName()
like in the below example:
// map a minimal API with GET and POST endpoints on the same routeapp.MapGet(“/minimalApi”, () =>{ NewRelic.Api.Agent.NewRelic.SetTransactionName(null, name: “minimalApi/Get”); return Results.Ok(“Get: minimalApi”);});app.MapPost(“/minimalApi”, () =>{ NewRelic.Api.Agent.NewRelic.SetTransactionName(null, name: “minimalApi/Post”); return Results.Ok(“Post: minimalApi”);});
You can read about setting names to transactions in our SetTransactionName doc.