.Net On Premise Web应用程序的Azure应用程序洞察 - 无法使用快速脉冲

问题描述 投票:0回答:1

我们为现有的Asp.Net MVC应用程序创建了azure应用程序洞察,我能够在Live metrics Stream上看到快速脉冲和连接的服务器。我只使用一个与所有较低环境相连的仪器键。返回的太多服务器正在向此应用程序报告。此视图中不会显示其他服务器。

如果我们检查了样本遥测,我们将收到以下错误。

AI (Internal): [Microsoft-ApplicationInsights-Extensibility-PerformanceCollector-QuickPulse] Unexpected error in QuickPulse infrastructure: System.InvalidOperationException: Can't start collection while it is already running.
 at Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor.Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.IQuickPulseTelemetryProcessor.StartCollection(IQuickPulseDataAccumulatorManager accumulatorManager, Uri serviceEndpoint, TelemetryConfiguration configuration, Boolean disableFullTelemetryItems)
 at Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule.OnStartCollection()
 at Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.Implementation.QuickPulse.QuickPulseCollectionStateManager.UpdateState(String instrumentationKey, String authApiKey)
 at Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule.StateThreadWorker(CancellationToken cancellationToken). QuickPulse data will not be available.

而不是在global.asax Beginrequest中尝试下面的c#代码的默认脚本。

    protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        TelemetryConfiguration configuration = new TelemetryConfiguration();
        configuration.InstrumentationKey = System.Configuration.ConfigurationManager.AppSettings["instrumentationKey"];
        QuickPulseTelemetryProcessor processor = null;

        configuration.TelemetryProcessorChainBuilder
            .Use((next) =>
            {
                processor = new QuickPulseTelemetryProcessor(next);
                return processor;
            })
            .Build();

        var QuickPulse = new QuickPulseTelemetryModule();
        QuickPulse.Initialize(configuration);
        QuickPulse.RegisterTelemetryProcessor(processor);
    }

由于这个问题大部分时间没有快速脉冲,请帮助我们找到问题。

c# azure azure-application-insights
1个回答
0
投票

您提到在Begin请求中有此代码。我不认为你想为每个请求调用此代码。您应该在Global Application_Start中执行此操作。

© www.soinside.com 2019 - 2024. All rights reserved.