Azure Functions - 应用程序见解 - 自定义遥测 - EventSource 实例已存在

标签 azure azure-functions azure-application-insights

我正在尝试按照 Insights Preview 中的说明进行操作我可以在其中创建自定义遥测数据。我完全按照说明进行操作。但也许我配置错误。

我在 local.settings.json 文件中设置了 APPINSIGHTS_INSTRUMENTATIONKEY,它似乎工作正常。但是,当我添加新的 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.

最佳答案

为了保持简单,我从一个新的 AF 项目(和一杯酒)开始。

以下代码有效:

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存储库,然后你才能看到它。几分钟后,但总比没有好。

关于Azure Functions - 应用程序见解 - 自定义遥测 - EventSource 实例已存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45292109/

相关文章:

Azure 函数 - 如何获取应用程序见解而不记录可用性测试结果

Azure 门户 - 删除数据库服务器

azure - 使用静态 token 连接到动态

sql - 导出 Azure SQL 数据库时出现错误 SQL71501

azure - 应用程序洞察使用情况

azure - 如何从 Azure 门户删除 Web App 的应用程序洞察监控(取消映射)?

azure - Azure 暂存槽是用于开发和生产还是仅用于生产

c# - 使用依赖注入(inject)对 Azure Functions 进行单元测试

c# - Azure 函数当时仅具有最大并发数

spring-boot - 未提供连接字符串(Azure Application Insights)