我正在尝试按照Insights Preview中的说明创建自定义遥测。我完全按照说明操作。但也许我的配置错了。
我在APPINSIGHTS_INSTRUMENTATIONKEY
文件中设置了local.settings.json
,似乎工作正常。但是当我添加一个新的TelemetryClient
时,我开始得到那些重复的错误(下面)。它在调用函数时发生。
我真的希望来自AF的遥测数据转到相同的AI仪器键,所以我可以一起看。
我也将Microsoft.Extensions.Logging
拉出来,因为我只想使用AI,如果这有任何区别的话。
有人有任何建议吗?
见下文......
TIA
ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Core: An instance of EventSource with Guid 74af9f20-af6a-5582-9382-f21f674fb271 already exists.
ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Core: An instance of EventSource with Guid 74af9f20-af6a-5582-9382-f21f674fb271 already exists.
Microsoft.WindowsAzure.ServiceRuntime Critical: 102 : Unexpcted Exception During Runtime Startup:
System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
---> System.Runtime.InteropServices.COMException: Invalid operation. (Exception from HRESULT: 0x80131022)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at <CrtImplementationDetails>.GetDefaultDomain()
at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
at <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
--- End of inner exception stack trace ---
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor()
ERROR: Exception in Command Processing for EventSource Microsoft-ApplicationInsights-Data: An instance of EventSource with Guid a62adddb-6b4b-519d-7ba1-f983d81623e0 already exists.
答案 0 :(得分:1)
我从一个新的自动对焦项目(和一杯葡萄酒)开始,以保持简单。
以下代码有效:
private static TelemetryConfiguration config = new TelemetryConfiguration { InstrumentationKey = System.Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY", EnvironmentVariableTarget.Process)};
private static TelemetryClient telemetryClient = new TelemetryClient(config);
此代码(直接来自预览帖子)不会:
private static TelemetryClient telemetryClient = new TelemetryClient();
private static string key = TelemetryConfiguration.Active.InstrumentationKey = System.Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY", EnvironmentVariableTarget.Process);
不幸的副作用是遥测不会自动显示在VS2017 Application Insights窗口中。您必须使用设置齿轮来选择所需的AI存储库,然后您才能看到它。几分钟后,但总比没有好。