azure-application-insights - 无法从代码触发 Snapshot Debugger 快照
问题描述
这是一个 Visual Studio 解决方案,其中包含一个以 .NET Framework 4.6 作为 UI 项目的 Asp.Net MVC 应用程序,以及其他几个 C# 类库项目。
我们将 Application Insights Nuget 包(包括 Snapshot Collector 包)添加到我们希望跟踪的解决方案中的所有项目。所有 Nuget 包都使用最新版本。
为了从代码中触发快照,我抛出了一个异常,如下所示:
try
{
throw new Exception("This is an AI test exception");
}
catch (Exception ex)
{
var ai = new TelemetryClient();
var props = new Dictionary<string, string> { { "Property1", "A test property value" } };
ai.TrackException(ex, props);
}
MVC项目的ApplicationInsights.config配置如下
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.SnapshotCollector.SnapshotCollectorTelemetryProcessor, Microsoft.ApplicationInsights.SnapshotCollector">
<IsEnabledInDeveloperMode>false</IsEnabledInDeveloperMode>
<HandleUntrackedExceptions>true</HandleUntrackedExceptions>
<ThresholdForSnapshotting>1</ThresholdForSnapshotting>
<ProblemCounterResetInterval>2.00:00:00</ProblemCounterResetInterval> <!--2 days-->
</Add>
</TelemetryProcessors>
我将应用程序发布到 Azure 并通过浏览应用程序多次调用异常。
此设置导致异常记录到 Application Insights,但没有快照。快照适用于未处理的异常。
第二次发生异常后不应该拍快照吗?
解决方案
请尝试以下步骤:
1)将您的更改IsEnabledInDeveloperMode
为文件。true
ApplicationInsights.config
true
意味着它将启用快照调试。
<IsEnabledInDeveloperMode>true</IsEnabledInDeveloperMode>
2)在您的代码之前添加它以检查加载程序集是否有错误。
var _ = typeof(SnapshotCollectorTelemetryProcessor);
3)在您的文件中添加bindredirect web.config
:
<dependentAssembly>
<assemblyIdentity name="Microsoft.ApplicationInsights" publicKeyToken="xxxxx" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.15.0.44797" newVersion="2.15.0.44797"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ApplicationInsights.SnapshotCollector" publicKeyToken="xxxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.7.0" newVersion="1.3.7.0" />
</dependentAssembly>
通常,活动将在%temp%
文件夹中。
如果这些都不起作用,
a)在Extensions --> Manage Extensions下禁用任何与已安装的扩展
b)在工具-->导入和导出设置-->重置所有设置下重置 vs设置
c)删除.vs
隐藏文件夹bin
和obj
文件夹。
推荐阅读
- r - 如何在数据框的列中嵌套表?
- react-native - 如何将参数传递给使用 useRoute() 的屏幕
- java - 如果满足某些条件,如何停止线程执行
- r - 如何选择两个事件之间的所有行
- regex - 正则表达式命令在第二个空格后获取字符串
- amazon-web-services - 使用 AWS Amplify 和 Pinpoint 进行分析
- r - 选择最频繁的组合,同时删除该组合的部分 R
- javascript - Chrome 和 Safari Mobile 上不同的自动调整大小
- linux - 树莓派 3:在 arm64 系统上运行 arm32 程序
- docker - Docker swarm overlay,单节点,服务之间无连接