如何解决Azure应用洞察-在高流量情况下不记录所有请求
“ Azure Application Insights”似乎没有在高流量环境中记录所有请求。
例如,当我们测试在10,000个请求中部署在“ Azure Service Fabric”上的.Net Core2.1 Web API应用程序,持续30分钟时,可以从“ Azure Application Insights”检索所有请求的详细信息通过使用日期时间戳作为过滤器的KQL,没问题。
当我们在30分钟内将负载增加到100,000个请求时,只有大约5-10%的请求记录在“ Azure Application Insights”上。
为什么“ Azure Application Insights”错过了在每秒处理约60个请求的高流量环境下的提取/记录?
是否需要任何其他配置? (或)仅一行代码不足以吸收由Azure Service Fabric服务提供服务的请求的详细信息?请澄清
使用了SDK
在Azure Service Fabric上用于提取的代码
return new WebHostBuilder().UseHttpSys()
.ConfigureServices(
services => services
.AddSingleton<StatelessServiceContext>(serviceContext)
.AddSingleton<ServiceFabricAppContext>(new ServiceFabricAppContext(){
NodeName = serviceContext.NodeContext.NodeName,ServiceHostIP=serviceContext.NodeContext.IPAddressOrFQDN,ServiceHostPort=FabricRuntime.GetActivationContext().GetEndpoints()[0].Port
} )
.AddSingleton<ITelemetryInitializer>((serviceProvider) => FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(serviceContext))) // Azure Service Fabric Telemetry Initializer
.UseContentRoot(Directory.GetCurrentDirectory())
.UseApplicationInsights()
.UseStartup<Startup>()
.UseEnvironment(environment)
.UseServiceFabricIntegration(listener,ServiceFabricIntegrationOptions.None)
.UseUrls(url)
.Build();
带有项目数的示例查询
解决方法
您可以从代码中禁用自适应采样。请注意,我在下面使用.UseApplicationInsights()
。而不是使用不推荐使用的.AddApplicationInsightsTelemetry
(下面将其删除)。
return new WebHostBuilder().UseHttpSys()
.ConfigureServices(
services => services
.AddSingleton<StatelessServiceContext>(serviceContext)
.AddSingleton<ServiceFabricAppContext>(new ServiceFabricAppContext(){
NodeName = serviceContext.NodeContext.NodeName,ServiceHostIP=serviceContext.NodeContext.IPAddressOrFQDN,ServiceHostPort=FabricRuntime.GetActivationContext().GetEndpoints()[0].Port
} )
.AddSingleton<ITelemetryInitializer>((serviceProvider) => FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(serviceContext)) // Azure Service Fabric Telemetry Initializer
.AddApplicationInsightsTelemetry(o =>
{
o.EnableAdaptiveSampling = false; // disabling adaptive sampling
}))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseEnvironment(environment)
.UseServiceFabricIntegration(listener,ServiceFabricIntegrationOptions.None)
.UseUrls(url)
.Build();
注意:我必须添加nuget Microsoft.ApplicationInsights.AspNetCore
注意:如果流量很大,禁用采样可能会导致节流和过多的网络流量。因此,您可能希望查看固定速率采样而不是自适应采样。请参阅Sampling in Application Insights。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。