If you are a regular reader of my blog, you've certainly seen my earlier post on how to integrate Application Insights telemetry in your HotChocolate based GraphQL backend.
IMPORTANT: Although the code below will still work, I would recommend to switch to the integrated OpenTelemetry functionality and send the information to Application Insights in this way.
Today I had to upgrade an application to HotChocolate 13 and (again) I noticed that the application no longer compiled. So for people who are using the ApplicationInsightsDiagnosticsListener
I shared, here is an updated version that works for HotChocolate 13:
As I wanted to track the full operation I have overwritten the ExecuteRequest
method, however if you only want to log any exception, I would recommend to override the RequestError
and ResolverError
methods:
More information
HotChocolate OpenTelemetry (bartwullems.blogspot.com)
GraphQL HotChocolate 11 - Updated Application Insights monitoring (bartwullems.blogspot.com)