简体   繁体   English

Application Insights 开发人员模式在 ASP.NET 核心 3.1 中不起作用

[英]Application Insights Developer Mode not working in ASP.NET Core 3.1

I'm using Application Insights in ASP.NET Core 3.1 application with the below code.我在 ASP.NET Core 3.1 应用程序中使用 Application Insights,代码如下。

 public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            ApplicationInsightsServiceOptions aiOptions = new ApplicationInsightsServiceOptions();
            aiOptions.DeveloperMode = true;
            services.AddApplicationInsightsTelemetry(aiOptions);
        }

As you can see i have enabled Developer mode to ensure that the telemetry data is pushed immediately (instead of waiting for 2-5 mins).如您所见,我已启用开发人员模式以确保立即推送遥测数据(而不是等待 2-5 分钟)。 However, it doesn't seem to be working.但是,它似乎不起作用。

Any ideas on how to make it work?关于如何使其工作的任何想法?

DeveloperMode simply means SDK channel will not buffer telemetry items in memory. DeveloperMode 仅表示 SDK 通道不会缓冲 memory 中的遥测项目。 Regular behavior is telemetry is buffered in memory, and once every 30 secs or when buffer has 500 items, they get pushed to backend.常规行为是遥测在 memory 中缓冲,并且每 30 秒一次或当缓冲区有 500 个项目时,它们被推送到后端。 Developer mode simply causes every item to be sent without buffering.开发者模式只是让每个项目在没有缓冲的情况下被发送。

The telemetry will be visible in Azure portal typically in 3-10 minutes (depending on backend/indexing/etc. delays, not controlled by SDK).遥测将在 Azure 门户中可见,通常在 3-10 分钟内(取决于后端/索引/等延迟,不受 SDK 控制)。 By enabling developer mode, only the SDK level buffering is disabled, leading to a max "gain" of 30 sec.通过启用开发者模式,只有 SDK 级别缓冲被禁用,导致最大“增益”为 30 秒。 Telemetry can still take several minutes to show up in portal.遥测仍可能需要几分钟才能显示在门户中。

(The intention behind behind developer mode is to show data instantly in local. ie Visual Studio itself shows telemetry while debugging. For that Developer is not required to be explicitly enabled. Attaching a debugger automatically enables developer mode) (开发人员模式背后的意图是在本地立即显示数据。即 Visual Studio 本身在调试时显示遥测数据。为此,不需要显式启用开发人员。附加调试器会自动启用开发人员模式)

Did it work before you enable the developer mode?在您启用开发者模式之前它是否有效?

When you register application insights into the DI container like this当您像这样将应用程序洞察力注册到 DI 容器中时

services.AddApplicationInsightsTelemetry()

It automatically assumes that you have in appsettings.json file a json object with the instrumentation key它会自动假定您在 appsettings.json 文件中有一个 json object 和检测密钥

  "ApplicationInsights": {
    "InstrumentationKey": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  },

Same when you deploy it as an azure web app, it automatically creates a configuration variable for you.当您将其部署为 azure web 应用程序时,它会自动为您创建一个配置变量。

I would suggest that you pass your instrumentation key into your ApplicationInsightsServiceOptions explicitly to make sure it is loaded properly.我建议您将检测密钥显式传递到 ApplicationInsightsServiceOptions 以确保正确加载它。

ApplicationInsightsServiceOptions aiOptions = new ApplicationInsightsServiceOptions();
aiOptions.InstrumentationKey("xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
aiOptions.DeveloperMode = true;
services.AddApplicationInsightsTelemetry(aiOptions);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 具有Application Insights的asp.net core 2记录器 - asp.net core 2 Logger with Application Insights ASP.NET Core MVC应用程序洞察在升级到.NET Core 1.1.1后停止工作 - ASP.NET Core MVC application insights stopped working after upgrade to .NET Core 1.1.1 ASP.NET Core 3.1:共享本地化不适用于 3.1 版 - ASP.NET Core 3.1 : Shared Localization not working for version 3.1 来自 ASP.NET Core 身份的 Application Insights 用户 ID - Application Insights User ID from ASP.NET Core identity 模拟不起作用 - Asp.Net core 3.1 应用程序与 Windows 身份验证托管在 IIS - Impersonation not working - Asp.Net core 3.1 application with Windows Authentication hosting in IIS asp.net 核心 3.1 web 应用程序中未显示的代码参考 - References of code not showing in asp.net core 3.1 web application 在 Asp.net Core 3.1 应用程序中处理子域 - Handle SubDomain in Asp.net Core 3.1 application 在数据库 ASP.NET Core 3.1 应用程序中保存和上传文件 - Save and upload files in database ASP.NET Core 3.1 application ASP.NET Core 3.1 应用程序中的第一个项目 - First project in an ASP.NET Core 3.1 application Razor 代码块在 ASP.NET Core 3.1 中不起作用 - Razor code blocks not working in ASP.NET core 3.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM