I am trying to set up and use application insights in a class library project. I would like to use it in offline mode while debugging in visual studio.
After following a few guides I have this:
(In the constructor for Engine.cs - the 'Main' class for my lib)
_telemetryClient = new TelemetryClient();
// Set session data:
_telemetryClient.Context.User.Id = Environment.UserName;
_telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
_telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
Then in the main method for the class:
var metrics = new Dictionary<string, double>();
var properties = new Dictionary<string, string>();
try
{
// Do stuff and track metrics code...
telemetryClient?.TrackEvent("Some Event", properties, metrics);
_telemetryClient?.Flush();
System.Threading.Thread.Sleep(1000);
}
catch (Exception exception)
{
_telemetryClient?.TrackException(exception, properties, metrics);
_telemetryClient?.Flush();
throw;
}
Since I wish the logging to be configured (eg Azure keys etc) in the calling code consuming the lbrary this project has no other configuration and no applicationinsights.config.
When I debug this in VS however, after choosing Select Application Insights Resource' -> last debug session, the 'Application Insights Search has no data.