How can I add custom operation to Azure Application Insights's Performance tab?

456 Views Asked by At

We have a GraphQL api that runs on .Net Core. Since all queries are made to the /graphql endpoint we only get one operation "POST /graphql" on the performance page of Azure Application Insights while a REST API would have allowed Aplication Insights to automatically give us the performance per endpoint (ex. GET /users, POST /events, etc...).

To still get performance indicators I added custom Telemetry to our code. When the code to retrieve the users is called I do this:

RequestTelemetry requestTelemetry = new RequestTelemetry
{
    Name = "UsersRequest"
};
var operation = _telemetryClient.StartOperation(requestTelemetry);

And when it is all done I do this:

operation.Telemetry.Success = true;
_telemetryClient.StopOperation(operation);
return result;

Then I can see the dependency calls wrapped up inside a "UsersRequest" when I open a "POST /graphql" operation like the screenshot below (imagine that "CustomMiddleware" says "UsersRequest"): enter image description here

That's already a great help, it's much more clear than having all DB requests under each other without structure.

The only thing missing it's that I can't see the "UsersRequest" or "CustomMiddleware" on the performance page as an operation itself. That would be a massive help, the performance page gives amazing insights. It would be super helpful to be able to see that "UsersRequest" has been called 500 times in the last 24h, that the performance has been degrading in the last 7 days or that the average duration is 50ms.

enter image description here

Thank you!

0

There are 0 best solutions below