什么是遥测配置以及为什么我们在 asp.net 核心中使用它?

What is a telemetry configuration and Why we use it in asp.net core?

我是 ASP.NET Core 1 的新手。我在 _Layout.cshtml 中看到了这样的代码部分。

@Html.ApplicationInsightsJavaScript(TelemetryConfiguration)

而且我不明白它是什么。

在您的应用程序中添加 TelemetryConfiguration 后,您可以从应用程序的服务器(后端)发送遥测数据。使用它,您可以添加客户端监控。这为您提供有关用户、会话、页面浏览量以及浏览器中发生的任何异常或崩溃的数据。

要启用 Application Insights,您需要将 “Microsoft.ApplicationInsights.AspNetCore” 添加到 project.json 文件

"Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final"

在 ConfigureServices 方法中像这样添加 Application Insights 服务-

public void ConfigureServices(IServiceCollection services)
{
    services.AddApplicationInsightsTelemetry(Configuration);
    services.AddMvc();
}

在_ViewImports.cshtml中,像这样添加注入-

@inject Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration TelemetryConfiguration 

您要从页面报告的任何自定义 javascript 遥测数据都应在此代码段之后注入。

@Html.ApplicationInsightsJavaScript(TelemetryConfiguration)

在此 post

中解释了完整的详细信息