I have used application insights in web api. It works well. Currently, our controller need call a class library (referred by nuget package). I need to use application insight in class library. There is no exception but nothing logged in Application insights. I write the code as following. Our TelemetryConfiguration have initialized in controller already.
var telemetryClient = new TelemetryClient();
var customEvent = new Microsoft.ApplicationInsights.DataContracts.EventTelemetry
{
Name = "helloworld",
};
// customEvent.Metrics.Add({ "latency", 42});
telemetryClient.TrackEvent(customEvent);
What should I do to make the application insights work?