We have noticed several situations where telemetry has not showed up in AI. After some digging I found entries like this in the log from FileDiagnosticsTelemetryModule.
Microsoft.ApplicationInsights.Extensibility.TraceSource Error: 43 : Process was called on the TelemetrySink after it was disposed, the telemetry data was dropped.
Sometimes telemetry arrives, sometimes not. There is only one other post I found on this but the article did not address much. Has anyone seen this before? Anything I should be looking at?
Startup.cs
ConfigureXXXServices
` services.AddSingleton<ITelemetryInitializer>(new RoleNameInitializer(ApplicationName));
services.AddSingleton(new OperationCorrelationTelemetryInitializer());
services.AddSingleton(new HttpDependenciesParsingTelemetryInitializer());
var aiOptions = new Microsoft.ApplicationInsights.AspNetCore.Extensions.ApplicationInsightsServiceOptions
{
EnableAdaptiveSampling = false,
DeveloperMode = false,
EnableDebugLogger = true,
EnableQuickPulseMetricStream = true,
ApplicationVersion = "2.0.0",
EnableDependencyTrackingTelemetryModule = true,
EnableRequestTrackingTelemetryModule = true,
AddAutoCollectedMetricExtractor = true,
EnableAppServicesHeartbeatTelemetryModule = true,
EnableEventCounterCollectionModule = true,
//EnablePerformanceCounterCollectionModule = true,
InstrumentationKey = Configuration.GetSection("Logging")["LoggingServiceApiKey"],
};
services.AddSingleton(typeof(ITelemetryChannel), new ServerTelemetryChannel() { StorageFolder = @"c:\TelemetryService_ReportingAgent" });
services.AddApplicationInsightsTelemetry(aiOptions);
services.AddApplicationInsightsTelemetryProcessor<CustomTraceOnlyProcessor>();
services.AddScoped<LogContext>();
services.AddSingleton<ITelemetryInitializer, LogContextInitializer>();
//if (Environment == "Local")
//{
Console.WriteLine("Setting up Telemetry Channel Diagnostics Tracing. See c:\\logs for details..");
services.AddSingleton<ITelemetryModule, Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.FileDiagnosticsTelemetryModule>();
services.ConfigureTelemetryModule<Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.FileDiagnosticsTelemetryModule>((module, options) =>
{
module.LogFilePath = "C:\\logs";
module.LogFileName = ApplicationName + "_TelemetryChannelLog.txt";
module.Severity = "Verbose";
});
//}
services.AddLogging(builder =>
{
builder.AddApplicationInsights(Configuration.GetSection("Logging")["LoggingServiceApiKey"]);
builder.AddFilter<ApplicationInsightsLoggerProvider>("", LogLevel.Information);
builder.AddFilter<ApplicationInsightsLoggerProvider>("Microsoft", LogLevel.Error);
});`
ConfigureXXX
` // Could these be the Telemetry Sinks getting disposed of too soon?
loggerFactory.AddDebug(LogLevel.Debug);
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
appLifetime.ApplicationStopping.Register(OnShutdown);
private void OnShutdown()
{
Console.WriteLine("Shutting Down");
this.TelemetryClient.Flush(); // this.TelemetryClient is a non-DI supplied instance (new) created in ctor..
Thread.Sleep(9000); // was 5000.
}`
Thanks for your time looking over this. Any help is appreciated.. Travis