gpt4 book ai didi

azure-application-insights - Application Insights .net core : Process was called on the TelemetrySink after it was disposed, 遥测数据被丢弃

转载 作者:行者123 更新时间:2023-12-05 06:57:39 27 4
gpt4 key购买 nike

我们注意到在 AI 中未出现遥测的几种情况。经过一些挖掘后,我在 FileDiagnosticsTelemetryModule 的日志中发现了这样的条目。

Microsoft.ApplicationInsights.Extensibility.TraceSource 错误:43:处理后在 TelemetrySink 上调用进程,遥测数据被丢弃。

有时遥测会到达,有时不会。我在这上面只找到了另外一篇文章,但是这篇文章没有涉及太多。有没有人见过这个?有什么我应该看的吗?

启动.cs

配置XXX服务

   ` 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);
});`

配置XXX

   `   // 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.
}`

感谢您花时间查看此内容。任何帮助表示赞赏..特拉维斯

最佳答案

您有 DeveloperMode=false,这意味着“TelemetryChannel 尊重其他属性定义的生产发送策略”。尝试将其设置为“DeveloperMode=true”,然后“TelemetryChannel 在应用程序的整个生命周期内立即将遥测数据发送到 Application Insights”。

关于azure-application-insights - Application Insights .net core : Process was called on the TelemetrySink after it was disposed, 遥测数据被丢弃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64866624/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com