1

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!

J Flex
  • 312
  • 1
  • 3
  • 11
  • I tried your code, and it shows in performance tab for me! ![](https://pasteboard.co/JtCTpuh.png) – krishg Oct 01 '20 at 12:22
  • That's so weird! Do you have special settings in Startup.cs? I simply have services.AddApplicationInsightsTelemetry(apiInsightsKey). – J Flex Oct 01 '20 at 13:17
  • Which version of Microsoft.ApplicationInsights.AspNetCore do you use? The latest is 2.15.0 but I use 2.8.1, I'll try to update it. – J Flex Oct 01 '20 at 13:20
  • I have `services.AddApplicationInsightsTelemetry` startup, but that won't matter here since you are logging custom telemetry. regarding version, yes please update. – krishg Oct 01 '20 at 13:53
  • any luck after update? – krishg Oct 02 '20 at 23:29

0 Answers0