在调试禁用应用程序的见解 [英] Disable application insights in debug

查看:198
本文介绍了在调试禁用应用程序的见解的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能自动禁用应用程序的见解使用调试配置当且仅在发布启用它?结果
是有可能做到这一点,而无需创建仅用于调试的另一个关键的仪器?
搜索结果
我已经散落在代码 trackevent 语句,内附他们调试预处理器检查里面不是一个理想的解决方案。



我目前的解决办法是将生成操作 ApplicationInsights.config 文件,这样它不会被复制到项目的输出目录,但这是不是可以根据活动构建配置进行自动化的过程。



有一个开发者模式,但需要手动更改(如果有可能有条件地设置配置文件,清空instrumentationkey解决的问题以及)
结果 http://apmtips.com/blog/2015/02/02/developer-mode/



感谢



参考:结果
HTTP://博客。 msdn.com/b/visualstudioalm/archive/2015/01/07/application-insights-support-for-multiple-environments-stamps-and-app-versions.aspx


< DIV CLASS =h2_lin>解决方案

由于在这个问题解释没有部署或不<部署ApplicationInsights.config; instrumentationkey>键< / instrumentationkey> 的产生块的事件。然后
你可以把代码中的仪表按键(仅在释放我的情况)

 #如果!$ DEBUG b $ b WindowsAppInitializer.InitializeAsync(仪表键); 
#ENDIF



每个 TelemetryClient 此调用后创建的具有正确的密钥,将跟踪事件,这样你就不必改变所有地方的代码。
不调用上述方法或离开参数空将阻塞事件,因为没有配置的键



基本上 ApplicationInsights的.config 文件将覆盖设置仪表键,删除<任何代码; instrumentationkey>键< / instrumentationkey> 里面它可以让你使用代码配置密钥。
如果您删除该文件完全不工作



下面是确认:
如果你要动态设置键 - 如果你想从你的应用程序将结果发送到不同的资源 - 例如,你可以省略从配置文件的密钥,并将其设置代码,而不是



参考: https://开头蔚蓝。 microsoft.com/en-us/documentation/articles/app-insights-configuration-with-applicationinsights-config/


How can I disable application insights automatically when using a debug configuration and enable it only on release?
Is it possible to do this without creating another instrumentation key only for debug?

I have trackevent statements scattered all over the code, enclosing them inside a debug preprocessor check is not an ideal solution.

My current solution is to set the Build Action of the ApplicationInsights.config file to None so that it's not copied to the project's output directory, but this isn't a process that can be automated based on the active build configuration.

There is a Developer Mode but needs to be changed manually (if it was possible to conditionally set the config file, emptying the instrumentationkey solved problem as well)
http://apmtips.com/blog/2015/02/02/developer-mode/

Thanks

References:
http://blogs.msdn.com/b/visualstudioalm/archive/2015/01/07/application-insights-support-for-multiple-environments-stamps-and-app-versions.aspx

解决方案

As explained in the question not deploying or deploying an ApplicationInsights.config without <instrumentationkey>key</instrumentationkey> block events from being generated. You can then put the instrumentation key in code (only on release in my case)

#if !DEBUG
    WindowsAppInitializer.InitializeAsync("instrumentation key");
#endif

Every TelemetryClient created after this call will have the correct key and will track events so you don't have to change the code in all places. Not calling the method above or leaving the parameter empty will block events because there isn't a key configured.

Basically the ApplicationInsights.config file overrides any code that set the instrumentation key, removing the <instrumentationkey>key</instrumentationkey> inside it will let you use code to configure the key. If you remove the file completely it doesn't work.

Here is the confirm: "If you want to set the key dynamically - for example if you want to send results from your application to different resources - you can omit the key from the configuration file, and set it in code instead."

Reference: https://azure.microsoft.com/en-us/documentation/articles/app-insights-configuration-with-applicationinsights-config/

这篇关于在调试禁用应用程序的见解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆