I have integrated the APM Agent for .NET in an ASP.NET Core application. I have added the HttpDiagnosticsSubscriber
in the call to UseElasticApm
, so all my controller actions are automatically instrumented.
For normal requests that are handled by a controller action, a trace will be logged that uses the name of the controller and action, and the name(s) of the action's parameters:
POST Object/Post {objectGuid}
But some browsers will send preflight requests, using the HTTP OPTIONS verb. And this is handled by my application, since I enabled the CORS middleware, to ensure the browser receives the right response to such a request.
Such a request looks something like this when done with curl:
curl -i -X OPTIONS "https://localhost:5001/object/5e8a35a3-e45e-4bea-bd72-5998877e13ef" -H "Origin: https://example.com" -H "Access-Control-Request-Method: POST"
The application will respond with headers to indicate if the browser should allow a POST request to that URL from a page on https://example.com:
HTTP/1.1 204 No Content
Date: Thu, 17 Dec 2020 16:13:06 GMT
Access-Control-Allow-Methods: POST
Access-Control-Allow-Origin: *
The problem is that the APM agent also captures traces for these OPTIONS requests. But since there is not controller and action handling the request, it uses the full URL for the name of the trace:
OPTIONS /object/5e8a35a3-e45e-4bea-bd72-5998877e13ef
On our production environment, we are seeing thousands of these 'unique' transaction names, and a warning that we are exceeding the limit.
! This view shows a subset of reported transactions.
The number of unique transaction names exceeds the configured value of 1000. Try reconfiguring your agents to group similar transactions or increase the value of
xpack.apm.ui.transactionGroupBucketSize
[Learn more in the docs]
So, what can we do?