找不到 TelemetryChannel 的来源找到了没有 InstrumentationKey 的遥测项目
Cannot find source of TelemetryChannel found a telemetry item without an InstrumentationKey
我有一个 asp.net 核心 3.1 控制台应用程序,它基本上是一个后台作业。我能够登录到应用程序洞察力。但是有一个持久日志每 15 分钟记录一次。
AI: TelemetryChannel found a telemetry item without an
InstrumentationKey. This is a required field and must be set in either
your config file or at application startup.
我已经查看了其他 SO 答案并尝试了推荐的解决方案,但仍然看到此日志。我看过的一些 post 是 How to find the source of "TelemetryChannel found a telemetry item without an InstrumentationKey"
根据这个建议,我尝试使用以下代码。
services.AddApplicationInsightsTelemetryWorkerService(
options =>
Configuration
.GetSection("ApplicationInsights")
.Bind(options)
);
NLog.LogManager.Configuration.FindTargetByName<ApplicationInsightsTarget>("ai").InstrumentationKey
= Configuration["ApplicationInsights:InstrumentationKey"].ToString();
我的应用设置有如下配置。
"ApplicationInsights": {
"InstrumentationKey": "instrumentation-key",
"DeveloperMode": false,
"EnableRequestTrackingTelemetryModule": true,
"EnableAdaptiveSampling": false,
"EnableActiveTelemetryConfigurationSetup": true
},
我使用的包是
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
有没有人幸运地解决了这个问题?
- 尝试在发布过程中将
appsettings.json
复制到应用程序根文件夹。
- 通过将 application insight 资源 id 添加到 csproj 进行检查:
<ApplicationInsightsResourceId>/subscriptions/abc</ApplicationInsightsResourceId>
- 尝试更新或降级
Microsoft.ApplicationInsights.WorkerService
的版本
看来这是2.15.0及以上版本的软件包存在的问题。
Microsoft.ApplicationInsights.WorkerService
我将版本还原为 2.14.0。这暂时解决了这个问题。
我有一个 asp.net 核心 3.1 控制台应用程序,它基本上是一个后台作业。我能够登录到应用程序洞察力。但是有一个持久日志每 15 分钟记录一次。
AI: TelemetryChannel found a telemetry item without an InstrumentationKey. This is a required field and must be set in either your config file or at application startup.
我已经查看了其他 SO 答案并尝试了推荐的解决方案,但仍然看到此日志。我看过的一些 post 是 How to find the source of "TelemetryChannel found a telemetry item without an InstrumentationKey"
根据这个建议,我尝试使用以下代码。
services.AddApplicationInsightsTelemetryWorkerService(
options =>
Configuration
.GetSection("ApplicationInsights")
.Bind(options)
);
NLog.LogManager.Configuration.FindTargetByName<ApplicationInsightsTarget>("ai").InstrumentationKey
= Configuration["ApplicationInsights:InstrumentationKey"].ToString();
我的应用设置有如下配置。
"ApplicationInsights": {
"InstrumentationKey": "instrumentation-key",
"DeveloperMode": false,
"EnableRequestTrackingTelemetryModule": true,
"EnableAdaptiveSampling": false,
"EnableActiveTelemetryConfigurationSetup": true
},
我使用的包是
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.14.0" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
有没有人幸运地解决了这个问题?
- 尝试在发布过程中将
appsettings.json
复制到应用程序根文件夹。 - 通过将 application insight 资源 id 添加到 csproj 进行检查:
<ApplicationInsightsResourceId>/subscriptions/abc</ApplicationInsightsResourceId>
- 尝试更新或降级
Microsoft.ApplicationInsights.WorkerService
的版本
看来这是2.15.0及以上版本的软件包存在的问题。
Microsoft.ApplicationInsights.WorkerService
我将版本还原为 2.14.0。这暂时解决了这个问题。